jfroebe has asked for the wisdom of the Perl Monks concerning the following question:
Hi all :)
Tonight I started and finished reading the Effective Perl Programming: Writing Better Programs with Perl ISBN 0-201-41975-0. In Item 54, page 224, I'm curious as to why the authors are comparing $@ with the empty string ''.
eval { open F1, $fname1 or die "$!"; open F2, $fname2 or die "$!"; # some other stuff ... }; if ($@ ne '') { warn "error in eval: $@\n"; }
I'm thinking the authors did the comparison for readability but my sleepy brain (been up since before time began this morning) is second guessing it. Sort of like when you know the word potato is spelled "p-o-t-a-t-o" but it still looks funny.
Wouldn't it be better to just look for a true $@ (non-zero and non-empty string)?
if ($@) { warn "error in eval: $@\n"; }
Am I suffering from a brain fart?
|
|---|