develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl #37624] print FILEHANDLE DWIMery doesn't always work

Thread Previous | Thread Next
Nicholas Clark
July 3, 2012 02:16
Re: [perl #37624] print FILEHANDLE DWIMery doesn't always work
Message ID:
On Sun, Jun 24, 2012 at 03:28:46PM -0700, Jesse Luehrs via RT wrote:
> Although the issue itself still exists, as of dee33c9 this behavior is
> now documented in perlfunc:
>     If you're storing handles in an array or hash, or in general whenever
>     you're using any expression more complex than a bareword handle or a
>     plain, unsubscripted scalar variable to retrieve it, you will have to
>     use a block returning the filehandle value instead, in which case the
>     LIST may not be omitted
> Is the actual behavior planned to be fixed, or can this issue be closed?

I don't think that you hit the right documentation. I think that the bug
really is this:

$ perl -le '$_ = "Pie"; print STDERR'
$ perl -le '$_ = "Pie"; print {STDERR}'
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
$ perl -le 'print STDERR "Pie"'
$ perl -le 'print {STDERR} "Pie"'

Why is the second a syntax error when the other three work?

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About