Monday, June 30, 2008

Another Perl Snippit

use Test::Simple tests => 2;

my $array_with_things = [0,1,2,3,4,5,6,7,8,9];
ok(scalar(@{$array_with_things} == 10) ;
@{$array_with_things} = ();  # Here's the magic
ok(scalar(@{$array_with_things}) == 0);

That's right it is a way of clearing an array of all elements. I always forget how to do it which is why it's here.