in reply to Re^2: Numeric as hash key returns undef...
in thread Numeric as hash key returns undef...

It actually gets weirder than that -- the . (concatenation) operator has higher precedence than a hash's auto-stringification. This confused a somewhat baffling bug for a few hours recently...
use Data::Dumper; $x{a} = "bare a"; $x{"a.b"} = "quoted a.b"; $x{a.b} = "unquoted a.b"; print Dumper(\%x);' __DATA__ $VAR1 = { 'ab' => 'unquoted a.b', 'a.b' => 'quoted a.b', 'a' => 'bare a' };

Replies are listed 'Best First'.
Re^4: Numeric as hash key returns undef...
by diotalevi (Canon) on Oct 24, 2006 at 21:46 UTC

    a.b cannot be auto-stringified because it does not match the pattern ^\w+$. What you're observing is the valid perl a.b becomng 'a'.'b' because strict allowed your bareword strings to be unquoted. At this point this has nothing to do with being a hash key. It's just that they're an expression. Enable strict to see what you were missing.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊