I've got a bit of a weird problem here. Basically, I'm trying to grab the contents of a page (in the below example, its google.com). I then try to find ALL of the words in the $RULES variable. The problem is, that its only matching 2 of the words (job and help). The code is;
print "Content-type: text/html \n\n";
my $RULES = qq|job
help
tools|;
use LWP::Simple;
my $html = get("http://www.google.com");
$html =~ s/\n//g;
# do counting of rules...needed later.
my @c_rules = split("\n",$RULES);
my $c_rules_cnt = $#c_rules; # get the number of entries..
# just so we can see the entries of the array..
print join(",",@c_rules) . " Words...<BR>";
# see if we can find *ALL* the words...
my $count = 0;
foreach (@c_rules) {
chomp;
print "Word: $_ <BR>";
if ($html =~ /$_/sig) {
$count++;
print "<font color=blue>Match good word.. $_ </font><BR>";
}
} # end 'foreach' for @c_rules
# if we didn't get *ALL* the rules, then we need to skip....
if ($count < $c_rules_cnt) { print "Bad...<BR>"; } else { print "Good..<BR>"; }
If I add something like this;
...it shows "yay!" fine. Can anyone see why my code would do this? Is it a problem with my code, or a problem with the method I'm using?
TIA.
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Code:
#!/usr/bin/perl print "Content-type: text/html \n\n";
my $RULES = qq|job
help
tools|;
use LWP::Simple;
my $html = get("http://www.google.com");
$html =~ s/\n//g;
# do counting of rules...needed later.
my @c_rules = split("\n",$RULES);
my $c_rules_cnt = $#c_rules; # get the number of entries..
# just so we can see the entries of the array..
print join(",",@c_rules) . " Words...<BR>";
# see if we can find *ALL* the words...
my $count = 0;
foreach (@c_rules) {
chomp;
print "Word: $_ <BR>";
if ($html =~ /$_/sig) {
$count++;
print "<font color=blue>Match good word.. $_ </font><BR>";
}
} # end 'foreach' for @c_rules
# if we didn't get *ALL* the rules, then we need to skip....
if ($count < $c_rules_cnt) { print "Bad...<BR>"; } else { print "Good..<BR>"; }
If I add something like this;
Code:
if ($html =~ /tools/i) { print "yay!"; } else { print "damn"; }...it shows "yay!" fine. Can anyone see why my code would do this? Is it a problem with my code, or a problem with the method I'm using?
TIA.
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

