in reply to Use Parsers To Get Chunk of HTML?
The matching could fail here, so you should check before using $1, otherwise you'll get the value remaining from the previous positive evaluation. You could also evaluate in list context:$whole_thing =~ m|<some unique html start string>(.*?)<end string>|s; $good_chunk = $1;
even if readability could suffer a bit here. This will assign $1 to $good_chunk if the regex matches, undef otherwise.($good_chunk) = $whole_thing =~ m|<some unique html start string>(.*?)<end string>|s;
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use Parsers To Get Chunk of HTML?
by Cody Pendant (Prior) on Jul 05, 2005 at 23:17 UTC |