develooper Front page | perl.beginners | Postings from April 2002

Re: wipe out elements in an array

Thread Previous
From:
bob ackerman
Date:
April 25, 2002 17:32
Subject:
Re: wipe out elements in an array
Message ID:
1ACAF1F4-58AD-11D6-9AC6-003065428126@pacbell.net
On Thursday, April 25, 2002, at 05:24  PM, Jeff 'japhy' Pinyan wrote:

> On Apr 25, Bryan R Harris said:
>
>> I'd like to remove all elements in an array that meet a certain criteria
>> without changing their order.  I'm sure this gets done all the time, but
>> I'm not sure how to do it...
>
> You want splice() instead.
>
>   perldoc -f splice
>
>

or use grep?:

@myarray = grep {$_ !=3 and $_ !=5} @myarray;


> --
> Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
> ** Look for "Regular Expressions in Perl" published by Manning, in 2002 *
> *
> <stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
> [  I'm looking for programming work.  If you like my work, let me know.  
> ]
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About