This will let you get around the nasty circumstance of multiple matches per line.while(<DATA>){ $before=$count; while($_=~/<\/p>/g){$count++} if($count>=3){ @segments=split/<\/p>/; for($before..2){ $toAdd.="$segments[$i]</p>"; $i++; } push@keep,$toAdd; last; }else{ push@keep,$_; } } print @keep; __DATA__ some</p>stuff</p> </p>other</p>things
In reply to Re: Extracting up to a certain string
by insensate
in thread Extracting up to a certain string
by Jaspersan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |