- Prison Code Breaker Diary -

=> aka: Nhật Kí Code Tù

Categories

A little quick trick to empty an array in Perl is to set its length to a negative number.


my @fruit = qw[ apple orange berry ];
print "Before: Fruit array has ".scalar( @fruit )." elements.\n";
$#fruit = -1;
print "After: Fruit array has ".scalar( @fruit )." elements.\n";
Have fun!@

0 comments

Post a Comment