On Thu, 22 Mar 2012 14:09:32 -0700
Leo Susanto <leosusa...@gmail.com> wrote:

> On Thu, Mar 22, 2012 at 1:54 PM, Manfred Lotz <manfred.l...@arcor.de>
> wrote:
> > On Thu, 22 Mar 2012 13:08:53 -0700
> > Leo Susanto <leosusa...@gmail.com> wrote:
> >
> >> you should do
> >>
> >> print {$hdl} "a line\n";
> >>
> >> instead of
> >>
> >> print $hdl "a line\n";
> >>
> >
> > Thanks for this. Didn't know that. Why is this required?
> > It works also without {}.
> >
> 
> I just tested against Activestate Perl 5.10.1 and without {} works.
> 
> I am probably quoting that based my experience on 5.6/5.8 (not 100%
> sure since I have deleted those older distros).
> 

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.

-- 
Manfred





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