Skip navigation.

Posts tagged with "perl"

firebug + undef %h vs. %h = ()

, ,

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:

#!/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

Read more...

Download Opera, the fastest and most secure browser
December 2009
M T W T F S S
November 2009January 2010
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31