How do I find the number of keys in a hash, like using $# for arrays?
How do I find the number of keys in a hash, like using $#
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
or just
if you’re already in a scalar context, e.g.
my $hash_count = keys %hashorprint 'bighash' if keys %hash > 1000.Incidentally,
$#arraydoesn’t find the number of elements, it finds the last index.scalar @arrayfinds the number of elements.