in reply to remove element from array

do you know the index of the element you want to get rid of? And do you know roughly what the other elements are? If yes to both, you could alter $mit[$index] so that it was the "lowest" element, then sort and shift. So if you knew all the elements were non-negative integers,
$mit[$index] = -1; shift sort @mit;
I don't know what the overhead of sort is, but this certainly should save on memory.

§ George Sherston

Replies are listed 'Best First'.
Re: Re: remove element from array
by demerphq (Chancellor) on Sep 11, 2001 at 20:38 UTC
    George,
    You cant use sort in void context. It doesn't mean anything. Ithink what you stated would have to be written like this:
    $mit[$inde]=-1; @mit=sort @mit; shift @mit;
    But as other posters have said its much more efficient to use splice().

    Yves
    --
    You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)