in reply to How to select a file handle depending on user options

You handle STDIN wrong (you need a filehandle or a typeglob - not a string) and it is usually better to use lexical variables for filehandles.

One way of doing it would be:

use IO::File; my $handle = $FILE ? do { IO::File->new($FILE) or fatal_error(".."); } : *STDIN; # later you can use <$handle>

Replies are listed 'Best First'.
Re^2: How to select a file handle depending on user options
by gg48gg (Sexton) on Jun 20, 2012 at 13:32 UTC
    so IO::File->new returns the file handle? I have never seen do used in a ternary like that. Interesting. Thank you.