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
Hello Todd,
Here’s another approach, using the /g modifier in scalar context and relying on the fact that . in a regex matches any character except a newline:
use strict; use warnings; my $A = "abc\ndef\nghi\n"; while ($A =~ /(.+)/g) { print "$1\n" unless $1 =~ /def/; }
Output:
13:59 >perl 1419_SoPW.pl abc ghi 14:00 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Regex match on implicit default variable ($_) in a script, not a one liner
by Todd Chester (Scribe) on Oct 24, 2015 at 05:15 UTC | |
by Athanasius (Cardinal) on Oct 24, 2015 at 06:20 UTC | |
|
Re^4: Regex match on implicit default variable ($_) in a script, not a one liner
by Todd Chester (Scribe) on Oct 24, 2015 at 04:52 UTC |