in reply to remove element from array

If there's a good chance that the element will be early on in the array, then something like this might be a bit faster.

my $i; foreach $i (0 .. $#mit2) { last if $mit2[$i] eq $rname; } splice @mit2, $i;

Oh, it also assumes that the element you want to lose only appears once in the array.

--
<http://www.dave.org.uk>

Perl Training in the UK <http://www.iterative-software.com>

Replies are listed 'Best First'.
Re: Re: remove element from array
by Monky Python (Scribe) on Sep 11, 2001 at 17:44 UTC
    Oh yes I forgot.
    I know the position of the element and the element appears only once.
    I tried splice and it's already a little bit faster.

    Thanks
    MP