in reply to Getting a Hash Name
If you want the hash name for debugging messages and that sort of thing, pass the name as an additional variable.
But what I want to talk about is the body of your subroutine. keys ${$hname} returns a list. Instead of going through the list item by item, in good C style, why not use idiomitic Perl: if you assign a list to a sscalar, the variable is assigned the number of elements in the list.
Tomsub check_limit { my ( $href, $name ) = $_; $name ||= '<unnamed>'; # assign text if not provided my $num = keys %{$href}; print "Hash: $hname has $num keys\n"; }
--
TTTATCGGTCGTTATATAGATGTTTGCA
|
|---|