Carlos Ramirez <[EMAIL PROTECTED]> wrote on 08/05/2006
05:52:48 PM:
> Unfortunately the above doesn't work. Printing $headers gives the
> string: 1/8?
Oooh, I just learned this the other day.
>From Programming Perl, Chapter 2.9:
When you evaluate a hash variable in a scalar context, it returns a true
value only if the hash contains any key/value pairs whatsoever. If there
are any key/value pairs at all, the value returned is a string consisting
of the number of used buckets and the number of allocated buckets,
separated by a slash. This is pretty much only useful to find out whether
Perl's (compiled in) hashing algorithm is performing poorly on your data
set. For example, you stick 10,000 things in a hash, but evaluating %HASH
in scalar context reveals "1/8", which means only one out of eight buckets
has been touched. Presumably that one bucket contains all 10,000 of your
items. This isn't supposed to happen.
If you just want to know what's in the hash, then I'd recommend
Data::Dumper (although you could also use a foreach my $key (keys %hash)
{} as well).
use Data::Dumper;
print Dumper(\%hash);
Todd
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]