Wednesday, April 13, 2011

Get the size of a hash

Solution
    print "size of hash:  " . keys( %hash ) . ".\n";Solution
    my $i = 0;
    
    $i += scalar keys %$hash_ref;  # method 1: explicit scalar context
    $i += keys %$hash_ref;         # method 2: implicit scalar context

No comments: