On Thu, 22 Mar 2012 20:06:35 -0400
Uri Guttman <[email protected]> wrote:
> On 03/22/2012 05:49 PM, Manfred Lotz wrote:
>
> >
> > In documentation about 'open' I found:
> >
> > Note that if you're storing FILEHANDLEs in an array, or if
> > you're using any other expression more complex than
> > a scalar variable to retrieve it, you will have to use a block
> > returning the filehandle value instead:
> >
> > print { $files[$i] } "stuff\n";
> > print { $OK ? STDOUT : STDERR } "stuff\n";
> >
> >
> > So it seems that it is perhaps a good style to use parenthesis
> > anyhow.
> >
>
> first off, those are called braces or curly braces, not parens. given
> 3 (or 4 if you count <>) paired chars all of which are heavily used
> in perl, it is important to use the proper names.
>
Thanks for amplifing this. As a non English speaker I wasn't careful
here.
> secondly, the docs don't say you should use braces for print handles,
> only you need them if your handle is something other than a single
> scalar value. no one uses braces for single scalar handles in
> general.
I understood what the docs said. I only made an assumption which you
say is wrong.
My idea behind using always braces was that then I'm always sure Perl
does the right thing.
> in fact there are many ways to print and indirect handles is
> a weak style IMO. OO style is cleaner (you need to load IO::File or
> IO::Handle). you can select the new handle with select() and later
> reselect STDOUT (there are idioms and modules for this).
>
As long as I use the "three-argument" form of open I don't see any
reason not to use open (at least in small scripts).
--
Manfred
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/