$has_field2 =~ s/field1:[\n]*\n\K(?!field2:).*(?=\nfield3:) /field2: valueB /msx;
c:\@Work\Perl\monks\Zu>perl -wMstrict -le "my $s = 'xxxyxxx'; $s =~ s/y /FOO /xms; print qq{'$s'}; " 'xxxFOO xxx'
In reply to Re^3: Efficient method to replace middle lines only when no match
by AnomalousMonk
in thread Efficient method to replace middle lines only when no match
by Zu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |