Re: display a hash...
by $Bill Luebkert other posts by this author
Jul 31 2004 11:09PM messages near this date
view in the new Beta List Site
RE: display a hash...
|
error using perlchat-0.1.1
bruce wrote:
> does perl provide a function similar to the 'C' sizeof that i can apply to a
> HASH/Structure to determine it's size...
There are no Structures in Perl. As far as hash sizes, the follwoing is
about all you can do :
perldata manpage
Scalar Values
...
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. This is pretty much
useful only to find out whether Perl's internal 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/16", which means
only one out of sixteen buckets has been touched, and presumably contains
all 10,000 of your items. This isn't supposed to happen.
> when dealing with sockets. i need a way of determining the size of the
> information that i pass back to the client...
What does that have to do with hashes ? You would need to serialize
the hash to send it on a socket and then you can easily determine the
length. Check Storable module for serializing data.
--
,-/- __ _ _ $Bill Luebkert Mailto:dbecoll@[...].net
(_/ / ) // // DBE Collectibles Mailto:dbe@[...].com
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
bruce
$Bill Luebkert
bruce
$Bill Luebkert
|