firebug + undef %h vs. %h = ()
Wednesday, 16. May 2007, 18:10:56
Tested out firebug today. Looks like the best web-debugging tool i've tried so far. Yes, it's for firefox, but still, a great tool for debugging web-applications using Ajax. Try it out for free here: Get Firebug
Also, A lot of people write that %hash = ( ) is the proper way of explicitly deallocating memory for an hash in Perl,
but this script proves (at least on Mac OS X) that this is not the case, and that undef %hash is the means for
destroying all elements in a hash:
- Ask
Also, A lot of people write that %hash = ( ) is the proper way of explicitly deallocating memory for an hash in Perl,
but this script proves (at least on Mac OS X) that this is not the case, and that undef %hash is the means for
destroying all elements in a hash:
#!/usr/local/bin/perl -l
use strict;
use warnings;
use Devel::Size qw( total_size );
my %a = map {$_ => 1} qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);
print 'after init hash: ', total_size(\%a);
keys %a = 1_000_000;
print 'after preallocate 1_000_000 elements: ', total_size(\%a);
%a = ( );
print 'after %a = ( ): ', total_size(\%a);
undef %a;
print 'after undef %a: ', total_size(\%a);
- Ask





