#! perl use strict; use warnings; use List::Util 'max'; my %h = ( '11c' => 'C', b => 'B', e22 => 'E', aaaaa => 'AAAA', ); if (%h) { my $last = max map { \$_ } values %h; printf "The last element added to the hash was %s\n", $$last; } else { print "No elements have been added to the hash\n"; }