in reply to IO::Handles ... any good?

The easy way:
my $file = $ARGV[0] || die "Synopsys: $0 <filename>" ; print "This is the filename to be processed: $file\n";

Replies are listed 'Best First'.
Re^2: IO::Handles ... any good?
by jwkrahn (Abbot) on Mar 22, 2009 at 19:20 UTC

    The  || operator has higher precedence than the  = operator so you should either enclose the assignment in parentheses:

    ( my $file = $ARGV[0] ) || die "Synopsys: $0 <filename>" ;

    or use the lower precedence  or operator:

    my $file = $ARGV[0] or die "Synopsys: $0 <filename>" ;

    Also, that test will fail if you have a file named  '0'.

      so you should either enclose the assignment in parentheses:

      Why? The intention is to check $ARGV[0], so || is perfectly acceptable.

      There's is a problem with both your solution and your parent's: It won't work for a file named "0". The following will, however:

      my ($file) = @ARGV or die(...);