Thank you, but unfortunately no.
The "def" will only be a part of the line. If "def" occurs anywhere in the line I want it included.
#!/usr/bin/perl # full script the following one liner: # $ echo -e "abc\ndef\nghi\n" | perl -wlne '! /def/ and print "$_";' # abc # ghi use strict; use warnings; use diagnostics; my $B = ""; my $A = "abcdef fhijkl mnopqr "; while ( $A =~ m{(.+)}g ) { $B .= "$1\n" unless $1 =~ /ijk/; } print "\$B = \n$B\n"; $B = ""; while ( $A =~ m{(.+)}g ) { $B .= "$1\n" while $1 =~ /ijk/; } print "\$B = \n$B\n";
$B =
abcdef
mnopqr
Use of uninitialized value $1 in concatenation (.) or string at ./ExtractTest.pl line 26 (#1)
Isn't "while" suppose to be the opposite of "unless"?
In reply to Re^2: Regex match on implicit default variable ($_) in a script, not a one liner
by Todd Chester
in thread Regex match on implicit default variable ($_) in a script, not a one liner
by Todd Chester
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |