develooper Front page | perl.perl5.porters | Postings from February 2011

[perl #84690] while(<>) doesn't become while(defined($_=<>)) if CORE::GLOBAL::readline is overridden

From:
Andrew Rodland
Date:
February 24, 2011 00:35
Subject:
[perl #84690] while(<>) doesn't become while(defined($_=<>)) if CORE::GLOBAL::readline is overridden
Message ID:
rt-3.6.HEAD-24085-1298409112-534.84690-75-0@perl.org
# New Ticket Created by  Andrew Rodland 
# Please include the string:  [perl #84690]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=84690 >


Ordinarily, Perl changes a construct like while(<>) or 
while(readline($handle)) into while(defined($_ = ...)). But if 
&CORE::GLOBAL::readline is defined when compiling these constructs, $_ won't 
be assigned and the defined check won't be added.

This is because when CORE::GLOBAL::readline is overriden, S_scan_inputsymbol 
in toke.c will generate an OP_ENTERSUB instead of an OP_READLINE, and so 
Perl_newLOOPOP will not recognize it as something to transform.

This is fairly low-impact since it only affects people who use 
CORE::GLOBAL::readline, but it definitely stands in contradiction to the docs.

(This affects every perl since at least 2002 up to blead).




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About