David Inglis wrote:
> 
> Is there a command to drop an element from an array, or what is the best
> way to do this.
> 
> Any help appreciated.

It depends.  If you want to remove an element based on its contents then use grep:

@array = grep $_ ne 'something', @array;

@array = grep !/something/, @array;


If you want to remove an element and you know its location in the array then use 
splice:

splice @array, 15, 1;  # remove 1 element at 16th position from the beginning

splice @array, -5, 2;  # remove 2 elements at 5th and 4th position from the end



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to