in reply to <> oddity ?
while(<>) [download]
reads from STDIN. Try this script:
while(<>) { print; } [download]
This should behave similar to yours under your 3 scenarios.
$ ./weird.pl sample.txt whereas $ ./weird.pl <sample.txt or $ cat sample.txt | ./weird.pl [download]