Aug 19, 2004 #1 EfratS MIS Joined Aug 4, 2004 Messages 15 Location CA Hi, how can I know the number of keys I have in a hash? Thanks.
Aug 19, 2004 #2 figmatalan Programmer Joined Jun 28, 2004 Messages 82 Location GB Code: %hash = (1 =>1, 2 => 2, 3 => 3); @keys = keys(%hash); $numkeys = @keys; print $numkeys; There will be better ways I'm sure, but you will end up with an array of the keys too in @keys Upvote 0 Downvote
Code: %hash = (1 =>1, 2 => 2, 3 => 3); @keys = keys(%hash); $numkeys = @keys; print $numkeys; There will be better ways I'm sure, but you will end up with an array of the keys too in @keys
Aug 19, 2004 #3 figmatalan Programmer Joined Jun 28, 2004 Messages 82 Location GB Or you can just do: Code: $numkeys = keys(%hash); Upvote 0 Downvote