Trap 3 - random failures? 

my %rgb = qw( yellow #FFFF00 purple #990099 orange #FF9900 );


# Normal usage:

print "orange: $rgb{orange}\n";


# Occasional reverse lookup required:

print "#990099: ", name_from_rgb('#990099'), "\n";
print "#FFFF00: ", name_from_rgb('#FFFF00'), "\n";
print "#FF9900: ", name_from_rgb('#FF9900'), "\n";

sub name_from_rgb {
  while(my($key, $value) = each %rgb) {
    return $key if $value eq $_[0];
  }
  return undef;
}