At 8:54 AM +0700 12/16/02, Komtanoo Pinpimai wrote:
However, regarding of large memory size that a hash requires, I'm hastitate to use "perl hash" to tell whether some elements exist or not. (I don't want to know their corresponding values, I'm just want to know if it exists)If you've got the memory the hash is probably the way to go, though there's a factor of two (more or less) size penalty. To wit:
use Devel::Size qw(total_size);
foreach (1..10000) {
$foo[$_] = undef;
$foo{$_} = undef;
}
print "Array: ", total_size(\@foo), "\n";
print "Hash : ", total_size(\%foo), "\n";
produces
[Daoine:~] dan% perl foo.pl
Array: 185572
Hash : 454490
Not great, certainly, but not likely to force out to swap or anything.
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

