If you are passing in command line args AND are redirecting/piping STDIN into your perl script, that you must not use <> to loop over the STDIN. Instead, use <STDIN> and refer to your arguments via the @ARGV array. Otherwise, Perl thinks that $ARGV[0] is a file name when it encounters just a <>.
This works:
% prepend.pl bob < some.txt
while <STDIN> {
print "$ARGV[0]: $_"
}
This doesn't:
% prepend.pl bob < some.txt
while <> {
print "$ARGV[0]: $_"
}
You may also want to check out
Multiple STDIN sources.