#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash = ( Matt => 24, Dana => 19, Eric => 28, Sara => 20, John => 17, Mike = +> 23, ); my @sorted = sort{ $hash{$a} <=> $hash{$b} } keys %hash; @hash{ @sorted[0,-1] } = @hash{ @sorted[-1,0] }; print Dumper \%hash;

Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

In reply to Re: Interchanging hash values by BrowserUk
in thread Interchanging hash values by mjab

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