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

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' );
, 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.


Dave


In reply to Re: Hash keys not DWIMming by davido
in thread Hash keys not DWIMming by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.