use strict; use warnings; local $/ = "<br>"; while ( <DATA> ) { print $1 if /Title:(.*?)<br>/s; } __DATA__ a whole lot of worthless stuff <b>Title: </b> STRING_I_WANT<br> more worthless meaningless stuff or sometimes <b>Title: </b>ANOTHER STRING_I_WANT<br>
update: This should take care of the extra stuff. I reread your requirement, everything from "Title:" to <br> and did what that specified instead of just the strings you wanted. The following only retrieves those strings and shows you how to put it in a variable (basically assign $1 to something) (see rob au's response which answers the question you asked). Good luck, here is the code:
use strict; use warnings; local $/ = "<br>"; while ( my $line =~ <DATA> ) { if ( $line =~ /Title:.*?<\/b>\n?(.*?)<br>/s ){ my $saved_var = $1; print "$saved_var\n" } } __DATA__ a whole lot of worthless stuff <b>Title: </b> STRING_I_WANT<br> more worthless meaningless stuff or sometimes <b>Title: </b>ANOTHER STRING_I_WANT<br>
-enlil
In reply to Re: Help with getting everything from X until Y
by Enlil
in thread Help with getting everything from X until Y
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |