O.K. Perl Monks, Lets say I have a file called myfilename.html that looks like this:
<!-- This is an example file --> <p>this is a link to a book called<br> <a href="http://www.foobar.tv/booklink.html"> <hr>etc etc
I wrote a small script that tells me which lines match a certain sting I enter on input, as in:
#>perl filematch.pl book
$matchtext = shift; $page = "myfilename.html"; open PAGE, $page; @page_text = <PAGE>; close PAGE; foreach $page_line (@page_text) { if ($page_line =~ m/$matchtext/) { print "There was an instance of $matchtext\n"; print "on this line:\n"; print "$page_line\n"; } }
The code above will tell me there is a match when $matchtext = "book", but it won't match when $matchtext = "booklink". I thought that even though, in my file, "booklink" is surrounded by non-whitespace, it should match nonetheless...
Anybody know what's wrong?
In reply to Simple REG/EX Question by mr_dont
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |