in reply to Re^2: Regex match on implicit default variable ($_) in a script, not a one liner
in thread Regex match on implicit default variable ($_) in a script, not a one liner
The "def" will only be a part of the line. If "def" occurs anywhere in the line I want it included.
This perhaps?:
#!/usr/bin/perl use strict; use warnings; use diagnostics; my $A = "abcdef fhijkl mnopqr redefine "; ( my $B = $A ) =~ s[(^.+\n)][ my $x = $1; $x !~ /def/ ? '' : $x ]gme; print "$B"; __END__ C:\test>1145825.pl abcdef redefine
|
|---|