Bug#271509: perl fails to warn about incorrect filehandle usage

Dominic Hargreaves dom at earth.li
Mon Apr 4 12:04:06 UTC 2016


On Sun, Apr 03, 2016 at 11:34:40PM +0300, Niko Tyni wrote:
> On Mon, Sep 27, 2004 at 05:49:19PM +1000, Brendan O'Dea wrote:
> > On Mon, Sep 13, 2004 at 11:54:34PM +1000, Anand Kumria wrote:
> > >I was mucking about playing with filehandles and discovered that in a.pl
> > >the output is incorrect whereas perl warns me about bad usage in b.pl
> > 
> > [a.pl] print $bar, "q\n";
> > [b.pl] print BAR, "q\n";
> > 
> > >They do, in essence, the same thing.
> > 
> > The difference is that the syntax in b.pl is unambiguously incorrect,
> > hence may be (and is) detected at compile-time as an error.  By
> > comparison, the syntax of a.pl is perfectly legal--consider:
> > 
> >   $bar = "hello, world";
> >   print $bar, "\n";
> 
> I'm not sure if this old bug should be kept open as a request for a
> runtime warning when printing out a stringified file handle, or just
> closed as a non-bug. Opinions?

I think it's unlikely that a suitable warning would be accepted; the
stringification is already defined behaviour and its use may be perfectly
valid in some situations. I think such a check, if it existed, should be
external to the interpreter. So my vote is to close this one as a non-bug.

Dominic.




More information about the Perl-maintainers mailing list