use strict; use warnings; use Data::Dump; my %colours = ( blue => "1", green => "2", red => "3", pink => "4", purple => "6" ); my %reverse_colours = reverse %colours; dd \%reverse_colours; printf "The colour corresponding to %d is %s\n", 1, $reverse_colours{1};