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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |