Thanks for the help ikegami.

I am thinking to submit a bug report on the documentation with the following suggestion for an addition:

Hash keys are always strings. Hash subscripts that are not strings are converted to strings before being used as keys. A subscript may be a string, simple bareword, list, array or expression. A string is used as-is. A bareword is treated as if it were a quoted string. A list is joined with the subscript separator C<$;> (see L<perlvar>). Note that it is not joined with the list separator C<$">, as it would be if it were being interpolated into a double quoted string. The following are equivalent: $hash{'a', 'b', 'c'} = 1; $hash{join($;, 'a', 'b', 'c')} = 1; Arrays are evaluated in scalar contex and the result is converted to a string. Note the difference between an array and a list, but also that an array can be interpolated into a list. Alternatively, an array can be interpolated into a double quoted string. In the following, 1 and 2 are the same, as are 3 and 4, as are 5 and 6. @array = ('a', 'b', 'c'); $hash{@array} = 1; # 1 $hash{'3'} = 1; # 2 $hash{(),@array} = 2; # 3 $hash{join($;, @array)} = 2; # 4 $hash{"@array"} = 3; # 5 $hash{join($",@array)} = 3; # 6 Everything else is evaluated as an expression and the result is converted to a string. Note that while references can be used as hash subscripts and are easily converted to string representation it is not easy to convert the string representation back to a reference. Note also that array slices are handled differently than either lists or arrays. They are processed like lists are in other contexts and yield the last element of the slice.

Any suggestions before it goes to bother those busy people would be much appreciated.


In reply to Re^2: hash key stringification by ig
in thread hash key stringification by ig

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.