in reply to Use Parsers To Get Chunk of HTML?

$whole_thing =~ m|<some unique html start string>(.*?)<end string>|s; $good_chunk = $1;
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:
($good_chunk) = $whole_thing =~ m|<some unique html start string>(.*?)<end string>|s;
even if readability could suffer a bit here. This will assign $1 to $good_chunk if the regex matches, undef otherwise.

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.

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
    Thanks for that, good point.


    ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
    =~y~b-v~a-z~s; print