in reply to <> and <ARGV> are the same thing, except when they aren't
Indeed, determining if what follows print is a file handle or not is very finicky. Since the parser always favours an expression to print over a handle, you can force unambiguity using curlies:
print { $fh } ...;
Note that contrary to what you said, indirect method calls are not affected, just the print operator.
$ echo foo | perl -MCGI -e'new CGI <>;' $
Update: Last bit is wrong.
$ perl -c -e'method $foo <>;' syntax error at -e line 1, near "<>" -e had compilation errors. $ perl -c -e'method $foo <ARGV>;' -e syntax OK
|
|---|