"be consistent" | |
PerlMonks |
Conditional creation of files - global or scoped filehandleby Anonymous Monk |
on May 06, 2016 at 10:05 UTC ( [id://1162341]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: Wherever possible I try to utilise a three-argument open and avoid bareword filehandles, such as: open my $out, '>', "$outfile" or die "$!"However there are cases when the creation of a subset of files in my script is dependent upon arguments provided by the user:
As a side note: i'm not sure that this is an appropriate means of conditionally opening files. This presents the problem that the filehandle is no longer global and thus inaccessible later on in the script. Is there a way around this or is this a situation where using a bareword filename is acceptable? Should the filename be declared outside of the loop first? Data being printed to $out is being created within a loop.
Back to
Seekers of Perl Wisdom
|
|