in reply to Function to measure size of a hash
Just wondering if there is a module or something out there in PERL that can be used to get the number of bytes in a hashI'm guessing you mean the number of bytes in all the values of a hash, which you could do like so
And make sure you use the bytes pragma if you're working with Unicode (unless you're using 5.8.0 which should deal with it seamlessly).my %hash = qw(foo one bar two baz three); my $hash_len = 0; $hash_len += length for values %hash; print "hash length is $hash_len\n"; __output__ hash length is 11
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Function to measure size of a hash
by simeon2000 (Monk) on Jul 24, 2002 at 15:35 UTC |