use warnings; use strict; my $hashref = { 'x' => 0, 'y' => 0, 'zzz' => 0 }; print scalar keys %$hashref;