%hash = ( a => 1, b => 2, c => 2 ); %inverted_hash = reverse %hash; print Dumper(\(%hash, %inverted_hash)); # Output: # $VAR1 = { # 'c' => 2, # 'a' => 1, # 'b' => 2 # }; # $VAR2 = { # '1' => 'a', # '2' => 'c' # };