in reply to Hash keys not DWIMming
Perl is treating '512_x64' as an expression, where 'x' is the x operator. See the output from the following:
perl -MO=Deparse -e "$h{512_x64} = 10; print $h{512_x64}, qq/\n/;"
Though the syntax checks out 'ok', deparse makes it clear that Perl is seeing "512_x64" as the expression, 512 x 64.
As a refresher, 512 x 64 is the same as 512512512512512512512512...... where the sequence '512' is repeated 64 times. This is an unusual case where 512_ is treated as a number. Consequently the '_' is silently dropped, and then the
, the => operator has the effect of wrapping "512_x64" in single quotes, so on that line you are properly populating the hash. But later on when you recall the hash value, the interpretation of $h{ ...... } is not protected by single quotes, explicitly or implicitly.x</x> operator stringifies it, so that the number 512 is stringified a +nd repeated 64 times.</p> <p>In your definition (ie, <c>%h = ( 512_x64 => 'value' );
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash keys not DWIMming
by JavaFan (Canon) on Oct 07, 2010 at 07:59 UTC | |
by kcott (Archbishop) on Oct 08, 2010 at 03:37 UTC | |
by JavaFan (Canon) on Oct 08, 2010 at 10:04 UTC | |
|
Re^2: Hash keys not DWIMming
by JavaFan (Canon) on Oct 07, 2010 at 08:37 UTC |