use strict; use warnings; my %hash=(key1=>'value1',key2=>'value2',key3=>'value4'); my $hash_ref=\%hash; print scalar keys %$hash_ref;