in reply to arguments to perl -e
The question is how to get the $var variable into the perl code since I apparently can not get in is as regular argument while using the -e parameter.Of course you can. There is no need for @ARGV to only contain a files list.
If the variable contains spaces, you may have to quote it.perl -le 'print shift' foo
You can even combine this with a file list passed as parameters:
or evenperl -e '$x = shift; while (<>) { print "$x: $_" }' $2 $1
perl -nle 'BEGIN { $x = shift } print "$x: $_"' $2 $1
|
|---|