in reply to Array element deletion

You could use the splice function:
splice @a, 0, 1; # | | # | +-- length # +----- offset #

Type perldoc -f splice on the command-line to get help on the splice function.

To delete an element based on the value...
for (0..$#a) { if ($a[$_] eq 'a') { splice @a, $_, 1; last; # exit the for loop because only want to delete # the first match } }

If you want to remove all occurance of an element, it's actually easier:
@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

    Why didn't you say that map with grep? I mean, that's what it is *there* for. Map's empty list is normally only important as a refinement on grep.

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
    splice?!? Why not just shift?
    shift @a;

    Of course, that doesn't work if you have to find and remove an array element. Then, indeed, splice or grep are the way to go.