[Chicago-talk] OPEN() conditional
Shlomi Fish
shlomif at shlomifish.org
Thu Jun 30 12:57:18 PDT 2011
Hi tiger peng,
On Thu, 30 Jun 2011 12:05:42 -0700 (PDT)
tiger peng <tigerpeng2001 at yahoo.com> wrote:
> if (-f '/blah/blah') {open F, "</blah/blab"} else { open F, "</blab"}.
>
1. Don't use globs for file-handles. Use lexical file handles instead
open my $fh, ...
2. Use three-args opens:
open my $fh, '<', '/blah/blab'
For the record, the original poster also did that mistake.
For more information see:
* http://perl-begin.org/tutorials/bad-elements/
* https://www.socialtext.net/perl5/ancient_perl
>
> maybe ?: will work too.
>
No reason why it shouldn't.
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
List of Portability Libraries - http://shlom.in/port-libs
What do you mean by “WDYM”?
Please reply to list if it's a mailing list post - http://shlom.in/reply .
More information about the Chicago-talk
mailing list