sub reorder(){ my ($item,$direction) = @_; if($direction eq 'up'){ $hash{$item,($item -1)} = $hash{ ($item -1), $item}; # maybe perl can automagically do the $tmp thing for me? } }