On Di. 27. Aug. 2013, 14:39:39, sprout wrote: > > A readline optimisation is causing the order of evaluation to change, > making the ‘local $/’ get executed too soon: > > Notice how the LVINTRO line is number 3 while readline is number 5: > > $ ./perl -Ilib -MO=Concise -e ' local $/ = <foo> ' > 6 <@> leave[1 ref] vKP/REFC ->(end) > 1 <0> enter ->2 > 2 <;> nextstate(main 1 -e:1) v:{ ->3 > - <1> null vKS/2 ->6 > - <1> ex-rv2sv sKRM*/129 ->4 > 3 <#> gvsv[*/] s/LVINTRO ->4 > 5 <1> readline[t3] sKS/1 ->6 > 4 <#> gv[*foo] s ->5 > -e syntax OK > > Here the numbers are 5 and 4, so the execution order is different: > > $ ./perl -Ilib -MO=Concise -e ' local $/ = do { <foo> } ' > 7 <@> leave[1 ref] vKP/REFC ->(end) > 1 <0> enter ->2 > 2 <;> nextstate(main 2 -e:1) v:{ ->3 > 6 <2> sassign vKS/2 ->7 > - <1> null sK*/1 ->5 > - <@> scope sK ->- > - <0> ex-nextstate v ->3 > 4 <1> readline[t3] sK/1 ->5 > 3 <#> gv[*foo] s ->4 > - <1> ex-rv2sv sKRM*/129 ->6 > 5 <#> gvsv[*/] s/LVINTRO ->6 > -e syntax OK > That optimization seems to be blatantly invalid. :-) % cat try.pl #!/usr/bin/perl use strict; use warnings; { package Ohai; sub TIEHANDLE { my $class = shift; bless {@_}, $class } sub READLINE { my $self = shift; $self->{readline}() } } our $xy = 42; tie *HDL, 'Ohai', ( readline => sub { print "the value of \$xy is [$xy]\n"; qw(a b c) }, ); { local $xy = do { <HDL> }; } { local $xy = <HDL>; } __END__ % perl try.pl the value of $xy is [42] Use of uninitialized value $xy in concatenation (.) or string at try.pl line 23. the value of $xy is [] --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=119487Thread Previous | Thread Next