J
John W. Krahn
bill said:Interesting topic.
I have two follow up questions regarding this:
1. Is there a simple modification of this one-liner that would short
circuit the unnecessary reading of lines when $seen{$ARGV} evaluates
to true?
perl -ne'/whatever/&&print("$ARGV\n")&&close(ARGV)'
2. A related issue is the resetting of $. . Suppose that I wanted
to check for /whatever/ only within the first 10 lines of every
file.
perl -ne'(1..10)&&/whatever/&&print("$ARGV\n")&&close(ARGV);eof&&close(ARGV)'
John