spydermonkey
Programmer
Hey everyone. I am having a little trouble parsing a website with a small regex. I believe it has something to do with the greediness of .* but I don't know of another way around it.
I test print $content prior to the regex and it's holding the entire source code as expected. After the regex the $1 keeps returning an uninitialized value error. I am trying to match EVERYTHING between
and
Does anyone have any ideas?
Thanks for your help!
Code:
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
##############################
# Configuration section
##############################
my $url =
"[URL unfurl="true"]http://rentacoder.com/RentACoder/misc/BidRequests/ShowBidRequests.asp?lngBidRequestListType=3&optSortTitle=2&lngBidRequestCa[/URL]
tegoryId=-1&txtMaxNumberOfEntriesPerPage=10&optBidRequestPhase=2&lngSortColumn=-6&blnModeVerbose=True&optBiddingExpiration=1"
;
my $file = "rac.txt";
##############################
# Do not edit below this line
##############################
open (LOG, "$file") or die "Cannot open file $file: $!";
my $saved = <LOG>;
if (!defined $saved)
{
$saved = "0";
}
close(LOG);
my $content = get("$url");
print $content;
$content =~ m!<td colspan="2"><font size="1" color="white"><b>Title(.*)<b>Search Results: </b>!;
$content = $1;
print "content: $1";
if ($saved ne "0" && $saved ne $content)
{
print "\a\a\a";
open(LOG, "> $file") or die "Cannot open file $file: $!";
print LOG $content;
close(LOG);
}
elsif ($saved eq "0")
{
open(LOG, "> $file") or die "Cannot open file $file: $!";
print LOG $content;
close(LOG);
}
I test print $content prior to the regex and it's holding the entire source code as expected. After the regex the $1 keeps returning an uninitialized value error. I am trying to match EVERYTHING between
Code:
<td colspan="2"><font size="1" color="white"><b>Title
and
Code:
<b>Search Results: </b>
Does anyone have any ideas?
Thanks for your help!