I guess from your post that when you write $h{512_x64} what you mean is $h{'512_x64'}. But, as you have noticed, perl doesn't do this for you.

In perldata Scalar value constructors, about the fifth paragraph (depending how you count), just before 'Version Strings', it says:

In fact, an identifier within such curlies is forced to be a string, as is any simple identifier within a hash subscript. Neither need quoting. Our earlier example, $days{'Feb'} can be written as $days{Feb} and the quotes will be assumed automatically. But anything more complicated in the subscript will be interpreted as an expression. This means for example that "$version{2.0}++" is equivalent to "$version{2}++", not to "$version{'2.0'}++".

And, in perldata Variable names it says:

Values are usually referred to by name, or through a named reference. The first character of the name tells you to what sort of data structure it refers. The rest of the name tells you the particular value to which it refers. Usually this name is a single identifier, that is, a string beginning with a letter or underscore, and containing letters, underscores, and digits.

Note the definition of identifier and remember that anything more complicated than an identifier within the subscript of a hash does not get implicit quotes. Knowing this, maybe you will not write $h{512_x64} when you mean $h{'512_x64'}, and perl can, once again, do what you mean.

Note also that there are many times when it is very convenient that what is inside the curlies of a hash subscript is evaluated as an expression. Hash subscripts would be much less useful if everything inside the curlies was implicitly quoted. Imagine if $key in the following were quoted. You wouldn't see the values of your environment variables or, if you happened to have an environment variable named '$key', you would see its value over and over.

foreach my $key (sort keys %ENV) { print "$key: $ENV{$key}\n"; }

In reply to Re: Hash keys not DWIMming by ig
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.