in reply to Regex match on implicit default variable ($_) in a script, not a one liner
I came up with something that seems to match your pipe/one liner closely. It doesn't chomp but you don't match against the end of line so I don't think that matters much.
use strict; use warnings; my $A="abc\ndef\nghi\n"; # remember matching is greedy but # without /s modifier '.' does not match \n my $B = join('', grep { ! /def/ } $A =~ /(.*\n)/g); print $B;
|
|---|