in reply to <> oddity ?
this
$ ./weird.pl sample.txt
is fundamentally different to
$ ./weird.pl <sample.txt or $ cat sample.txt | ./weird.pl
the first passes a filename as argument while the latter two pipe the content of this file into STDIN.
See ARGV for a way to solve this.
Cheers Rolf
( addicted to the Perl Programming Language)
In Section
Seekers of Perl Wisdom