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.

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. 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).

uri

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to