in reply to Removing an element from an array

Actually, unless it is the last element, you might have to use 'splice' using null doesn't seem to work, and using undef doesn't remove the array element. Consider the following code and output:
#!/usr/bin/perl my @array = ( "I", "am", "not", "a", "crook" ); print "Here is the original array\n"; my $ctr = 1; foreach( @array ) { print "$_\t $ctr\n"; $ctr++; } print "\n\nNow null it!\n"; $array[2] = NULL; $ctr = 1; foreach( @array ) { print "$_\t $ctr\n"; $ctr++; } print "\n\nNow undef it!\n"; $array[2] = undef; $ctr = 1; foreach( @array ) { print "$_\t $ctr\n"; $ctr++; } print "\n\nNow splice it!\n"; splice(@array, 2, 1); $ctr = 1; foreach( @array ) { print "$_\t $ctr\n"; $ctr++; }
************OUTPUT***************
/tmp >./test
Here is the original array
I        1
am       2
not      3
a        4
crook    5


Now null it!
I        1
am       2
NULL     3
a        4
crook    5


Now undef it!
I        1
am       2
         3
a        4
crook    5


Now splice it!
I        1
am       2
a        3
crook    4