in reply to Swapping Two Hash Values

maybe a little off topic, but you could replace the reorder sub with something as simple as this:
sub reorder { my ($item,$direction) = @_; if($direction eq 'up'){ @hash{$item,$item-1} = @hash{$item-1,$item}; } }
which is easier on the eyes, and no temp variables.

-enlil

Replies are listed 'Best First'.
Re: Re: Swapping Two Hash Values
by Cody Pendant (Prior) on May 28, 2003 at 00:47 UTC
    @hash{$item,$item-1} = @hash{$item-1,$item};

    Aha! Now I see what I was doing wrong -- I had

    $hash{$item,$item-1} = $hash{$item-1,$item};
    

    So I probably created another key which is not 5 but 5-undef or something?

    Thank you both very much.
    --

    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D