in reply to Re: Variable name missing in warning
in thread Variable name missing in warning
> perl -MO=Deparse,-q use warnings; my (%a, %b, $c); my $x = "$a{'foo'} $b{'bar'} $c" __END__ use warnings; my(%a, %b, $c); my $x = $a{'foo'} . ' ' . $b{'bar'} . ' ' . $c; - syntax OK
-q reveals the mentioned optimization of string-interpolations, but the variable name is not affected.
lanx@nc10-ubuntu:~$ perl -w -MO=Concise my (%a,%b,$c); my $x = "$a{'foo'} $b{'bar'} $c"; o <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -:1) v:{ ->3 7 <@> list vKPM/128 ->8 3 <0> pushmark vM/128 ->4 4 <0> padhv[%a:1,3] vM/LVINTRO ->5 5 <0> padhv[%b:1,3] vM/LVINTRO ->6 6 <0> padsv[$c:1,3] vM/LVINTRO ->7 8 <;> nextstate(main 2 -:2) v:{ ->9 n <2> sassign vKS/2 ->o - <1> ex-stringify sK/1 ->m - <0> ex-pushmark s ->9 l <2> concat[t8] sKS/2 ->m j <2> concat[t7] sKS/2 ->k h <2> concat[t6] sKS/2 ->i d <2> concat[t5] sK/2 ->e b <2> helem sK/2 ->c 9 <0> padhv[%a:1,3] sR ->a <------- a <$> const[PV "foo"] s ->b c <$> const[PV " "] s ->d g <2> helem sK/2 ->h e <0> padhv[%b:1,3] sR ->f <------- f <$> const[PV "bar"] s ->g i <$> const[PV " "] s ->j k <0> padsv[$c:1,3] s ->l <------- m <0> padsv[$x:2,3] sRM*/LVINTRO ->n - syntax OK
I thought this is only a negligible bug, such that after fixing $a{foo} the following $b{bar} would be visible, but that's unfortunately not the case:
> perl -w my (%a, %b, $c); $a{foo}="FIXED"; my $x = "$a{'foo'} $b{'bar'} $c"; __END__ Use of uninitialized value in concatenation (.) or string at - line 3. Use of uninitialized value $c in concatenation (.) or string at - line + 3.
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Variable name missing in warning (source)
by tye (Sage) on Apr 03, 2014 at 06:24 UTC | |
by LanX (Saint) on Apr 03, 2014 at 10:02 UTC | |
by tye (Sage) on Apr 03, 2014 at 20:59 UTC | |
by LanX (Saint) on Apr 03, 2014 at 21:14 UTC |