use Data::Dumper; my %h = (1 => 2, a => "b", c => 2); print Dumper [ my %x = reverse %h ];