use strict; use warnings; use List::Util qw(reduce); my $maxkey = reduce { $hash{$a} > $hash{$b} ? $a : $b } keys %hash; my $minkey = reduce { $hash{$a} < $hash{$b} ? $a : $b } keys %hash; @hash{$minkey,$maxkey} = @hash{$maxkey,$minkey};

Makeshifts last the longest.


In reply to Re: Interchanging hash values (List::Util) by Aristotle
in thread Interchanging hash values by mjab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":