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

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}]

Replies are listed 'Best First'.
Re^11: the annoying keys "key" and "value"
by ikegami (Patriarch) on Dec 24, 2010 at 03:35 UTC

    First of all, it doesn't make sense to use a hash when you are encoding order for obvious reasons

    Exactly!

    The proper Perl structure for which would be:

    No, then you'd have to do

    (keys(%$param))[0]

    instead of

    $param->{key}

    to get the key. That's much worse.

      Let me try to nail at least one tentacle of this jellyfish to the wall: When you're trying to represent a hash, you aren't trying to represent ordering between the elements. That much we agree on. So why would someone try to represent a hash with an array of two element hashes each with the keys "key" and "value"?

        So why would someone try to represent a hash with an array of two element hashes each with the keys "key" and "value"?

        "Represent a hash" makes no sense. I presume you mean "implement an associative array".

        Someone would do that if they wanted to preserve the order of the tuples. We've covered this multiple times already.

Re^11: the annoying keys "key" and "value"
by Anonymous Monk on Dec 24, 2010 at 03:09 UTC
    why not objects? :)