************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++; }
/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
In reply to Re: Removing an element from an array
by Anonymous Monk
in thread Removing an element from an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |