mr_dont has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Simple REG/EX Question
by Ovid (Cardinal) on Feb 25, 2002 at 22:10 UTC | |
|
Re: Simple REG/EX Question
by screamingeagle (Curate) on Feb 25, 2002 at 22:08 UTC | |
|
Re: Simple REG/EX Question
by YuckFoo (Abbot) on Feb 25, 2002 at 22:17 UTC |