How can I mix command line arguments and filenames for <> in Perl?
- by Jimmeh
Consider the following silly Perl program:
$firstarg = $ARGV[0];
print $firstarg;
$input = <>;
print $input;
I run it from a terminal like:
perl myprog.pl sample_argument
And get this error:
Can't open sample_argument: No such file or directory at myprog.pl line 5.
Any ideas why this is? When it gets to the < is it trying to read from the (non-existent) file, "sample_argument" or something? And why?