On Mon, 17 Oct 2005 00:54:28 -0500, M. Lewis wrote: > Charles K. Clarkson recently replied to Sreedhar Reddy in which one of > the corrections he made was: > > open my $fh, '<', $input_file or die qq(Cannot open "$input_file": $!); [...] > When I have opened a file, I have always done: > > open (FILE, $file) || die "Cannot open $file :$!"; [...] > My question is, which way is better, and why is it better? My assumption > is Charles' method is better, but I would appreciate knowing why.
Charles' method is also better because he doesn't have to remember to put the parentheses around the arguments to open(). You have used the higher precedence || operator which means that your program would have a nasty bug without those parentheses. I use 'or' and 'and' for all operations where a control flow change is intended, and || and && only where computing an expression is intended. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>