Leser: 16
1 2 3 4 5 6 7 8 9 10 11 12 13
my $hash_ref = foo(); print "Menge: " . scalar %{$hash_ref}; # liefert "3/8", ich erwarte aber 4 # und was heißt 3/8 genau, wofür stehen die Zahlen? sub foo { my %test = ( 1 => 'foo', 2 => 'bar', 3 => 'foobar', 4 => 'barfoo', ); return \%test; }
scalar (keys %$hashref)
1
2
3
4
If you evaluate a hash in scalar context, it returns false if the hash
is empty. If there are any key/value pairs, it returns true; more
precisely, the value returned is a string consisting of the number of
used buckets and the number of allocated buckets, separated by a slash.