in reply to Re: Question about warn statement
in thread Question about warn statement

unless (open(FILE,">temp")) {

This is fine and dandy. I used to prefer it. But, it should come with a caveat... If you like to autovivify your filehandles, using that construct might cause a problem. Consider:

unless (open my $fh, '<', 'file') { # . . . }
In that code, $fh is lexical to the unless block. That probably isn't what you want because you only enter the block if the open fails. This pitfall may be more likely to come up when changing existing code than when writing new code altogether.

You can get around it by declaring $fh prior to the unless but, now anyway, I prefer to avoid it by using

open my $fh, '<', 'file' or do { # . . . };
instead. That also puts the emphasis back on the open statement itself.

-sauoq
"My two cents aren't worth a dime.";