Chas. Owens wrote:
This is a job for an HTML parser, not a single regex.
Thank you for telling me about HTML::Parser, which I will use in future.
Gunnar Hjalmarsson wrote:
print "$1\n" while $content =~ m|(<a\s*href="\s*http://.*?">)|gis;
Thank you for your script (which works!) and most of all for the illuminating
line above, which replaces my "if" construct:
if (m|(<a\s*href="\s*http://.*?">)|sg) {print "$1\n";}
I was just reading this in Jeffrey Friedl's book "Mastering Regular
Expressions"::
"If you consider yourself an expert, don't tell me you've never wasted way too
much time trying to understand why
if (m/.../g)
wasn't working, because I probably wouldn't believe you." (p 203)
That was puzzling until I saw your reply and realized that there is no looping
in an "if" as there is in a "while" and so, even if the entire file is slurped
into a single string, the g modifier will not function as expected in an "if"
block as it will within a "while" block.
Thank you both once more.
Chandra
04 Feb 08
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/