I often need to run some single-line Perl for fast data management, like
some_command | perl -lne 'print if /abc/'
Reading from the channel, I do not need a loop around the arg arg file name. How can I achieve the following?
some_command | perl -lne 'print if /$ARGV[0]/' abc
This gives an error:
Can't open abc: No such file or directory.
I understand what '-n' does
while(<>) {.... }
around my program, and <> accepts args as file names, but doing the following each time is a little impractical
#/bin/sh while read line do some_command | perl -lne 'BEGIN{$val=shift @ARGV} print if /$val/' "$line" done
Is there a better way to get the Perl ONE-LINER command line arguments βinsideβ without interpreting them as file names?
source share