in reply to Array element deletion
splice @a, 0, 1; # | | # | +-- length # +----- offset #
for (0..$#a) { if ($a[$_] eq 'a') { splice @a, $_, 1; last; # exit the for loop because only want to delete # the first match } }
@a = map { /a/ ? () : $_ } @a;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Array element deletion
by diotalevi (Canon) on May 04, 2004 at 14:34 UTC | |
|
Re: Re: Array element deletion
by revdiablo (Prior) on May 04, 2004 at 18:33 UTC | |
|
Re: Re: Array element deletion
by bart (Canon) on May 04, 2004 at 16:21 UTC |