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

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'.

Replies are listed 'Best First'.
Re^3: IO::Handles ... any good?
by ikegami (Patriarch) on Mar 22, 2009 at 19:25 UTC

    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(...);