in reply to Extracting up to a certain string
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
|
|---|