in reply to Removing an element from an array
I found out that I have to introduce a temporary variable, because the first splice modifies @a
sub rm ($@) { my ($e,@a) = @_; my @t = @a; (splice(@a,0,--$e),splice(@t,++$e)); } my @array = (1..10); # # remove the 5th Element # @array = &rm(5,@array); print join ("\n",@array) . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing an element from an array
by Anonymous Monk on Apr 26, 2001 at 15:36 UTC |