use Data::Dumper; my %hash=(foo => 'bar', bar => 'baz'); %hash=(%hash, reverse %hash); print Dumper \%hash;