http://www.perlmonks.org?node_id=219495


in reply to Re: random number
in thread random number

Given that you know the index of the item you want to remove from the array, it would be much more efficient to use splice instead of grep to remove the item from the array.

#replace my @newarray = grep {$_ !=$element} @array; #remove the element #with splice @array, $index, 1; #remove item from array; # and remove this. No need as the array has been modified. # @array = @newarray; #reset the array

Examine what is said, not who speaks.