in reply to Re: how to check which index $x is in an hash
in thread how to check which index $x is in an hash

I think your more succinct version will have a problem with the first key. This is because $_ going into the map is going to be 0 thus prev => $keys[0 - 1] will result in prev => 10. At the other end, I think that next => $keys[$#keys + 1] will do the right thing as pointing off the end of the array should result in undef.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: how to check which index $x is in an hash
by GrandFather (Saint) on May 21, 2007 at 22:19 UTC

    Argh, you are quite right! I "checked" it, honest, I just didn't notice the line that says "10 precedes 1"!


    DWIM is Perl's answer to Gödel