http://www.perlmonks.org?node_id=1006798


in reply to Re: perl substitue till found pattern in aline
in thread perl substitue till found pattern in aline

This variant is a little bit more easy to read and should be executed faster.

while (<DATA>) { my ( $left, $right ) = split /-1/, $_, 2; $left =~ s/ /,/g; print join '-1', $left, $right; } __DATA__ 01 fines name 2222 -P sws -1 reee.tee rrt 02 fi si 2232 -P sqww -1 re.wqw ttf 02 fi si-1 2232 -P sqww -1 re.wqw ttf