in reply to Re^3: Problem with perlcritic when using Moose object
in thread Problem with perlcritic when using Moose object
$hashref->{-option} reliably interpreted as $hashref->{'-option'}
Interestingly, the former is actually interpreted as an expression (note the "negate" below), but the because of the properties of unary -, -bareword is the same as "-bareword". As of v5.26, "Bareword constant strings are now permitted to take part in constant folding."
$ perlbrew exec --with 5.24.4,5.26.2 perl -MO=Concise -wMstrict -e 'my + %hash; print $hash{-foo}' perl-5.24.4 ========== b <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:*,&,{,x*,x&,x$,$ ->3 3 <0> padhv[%hash:2,3] vM/LVINTRO ->4 4 <;> nextstate(main 3 -e:1) v:*,&,{,x*,x&,x$,$ ->5 a <@> print vK ->b 5 <0> pushmark s ->6 9 <2> helem sK/2 ->a 6 <0> padhv[%hash:2,3] sR ->7 8 <1> negate[t2] sK/1 ->9 7 <$> const(PV "foo") s/BARE ->8 -e syntax OK perl-5.26.2 ========== 8 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:*,&,{,x*,x&,x$,$ ->3 3 <0> padhv[%hash:2,3] vM/LVINTRO ->4 4 <;> nextstate(main 3 -e:1) v:*,&,{,x*,x&,x$,$ ->5 7 <@> print vK ->8 5 <0> pushmark s ->6 - <1> ex-helem sK/2 ->7 6 <+> multideref($hash{"-foo"}) sK ->7 - <0> ex-padhv sR ->6 -e syntax OK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Barewords with unary operators (was: Problem with perlcritic...)
by haj (Vicar) on Oct 06, 2018 at 19:47 UTC |