in reply to Re^6: the annoying keys "key" and "value"
in thread the annoying keys "key" and "value"

If it's pathalogical, what would be nonpathological?

$param->{'key'} # { key => $key, value => $value }

is slightly clearer than

$param->[0] # [ $key, $value ]

and much more clearer than

(keys(%$param))[0] # { $key => $value }

Update: I missed this:

The non-pathological representation would have: $hash{$key}=[$value1, $value2, $value3,...]

But it's not true. That doesn't maintain order, so the question remains. What would be nonpathological?

Replies are listed 'Best First'.
Re^8: the annoying keys "key" and "value"
by jabowery (Beadle) on Dec 23, 2010 at 23:38 UTC
    "That doesn't maintain order"

    The array has the order.

      Really? Please recreate the original from
      { a=>[1,3,5], b=>[2,4,6], }

      If you answered the following, you would be wrong.

      a=>1 a=>3 a=>5 b=>2 b=>4 b=>6

      As far as you know, the original order was

      b=>2 b=>4 a=>1 b=>6 a=>3 a=>5
        First of all, it doesn't make sense to use a hash when you are encoding order for obvious reasons. Secondly, the notation you've chosen conflates markup with Perl hashes so let me clarify your challenge:

        Original:

        <b>2</b> <b>4</b> <a>1</a> <b>6</b> <a>3</a> <a>5</a>
        The proper Perl structure for which would be:
        [{b=>2},{b=>4},{a=>1},{b=>6},{a=>3},{a=>5}]