in reply to Re^2: Break one liner command line script after first match
in thread Break one liner command line script after first match
Hi,
Be aware of the subtle difference between:
Of course, I saw the subtle difference, and how you used
.. print ($1) ...
you gets:perl -MO=Deparse -ne'/(data)/ && print $1 && last' file.txt
but usingLINE: while (defined($_ = <ARGV>)) { print $1 && last if /(data)/; }
gives:perl -MO=Deparse -ne'/(data)/ && print ($1) && last' file.txt
Which is same as this:LINE: while (defined($_ = <ARGV>)) { last if /(data)/ and print $1; }
perl -MO=Deparse -ne'/(data)/ && print $1 and last' file.txt
LINE: while (defined($_ = <ARGV>)) { last if /(data)/ and print $1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Break one liner command line script after first match
by McA (Priest) on Oct 30, 2013 at 13:32 UTC |