in reply to Why is +CONST left to a fat comma not treated as in $hash{+CONST}?
$ perl -MO=Deparse,-p -Mstrict -e 'sub b;sub c;(1+b=>c)' sub b; use strict; ((1 + 'b'), c()); sub c;
The behaviour can be sometimes surprising, but it's documented in perlop:
The special quoting behavior ignores precedence, and hence may apply to part of the left operand:That example prints something like "1314363215shiftbbb", because the => implicitly quotes the "shift" immediately on its left, ignoring the fact that "time.shift" is the entire left operand.print time.shift => "bbb";
Update: See also Using constants as hash keys.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why is +CONST left to a fat comma not treated as in $hash{+CONST}?
by Darkwing (Scribe) on Jan 05, 2024 at 15:24 UTC |