Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: filtering an array

by swampyankee (Parson)
on Sep 02, 2012 at 01:35 UTC ( #991223=note: print w/ replies, xml ) Need Help??


in reply to filtering an array

Well, what have you tried?

There is, of course, more than one way to do this. One way is to use grep:

my @after; @after = grep { !/[GT]/ } @positions;

which is, in essence,

my @after; foreach @positions { push(@after, $_) if (!/[GT]/); }

I tend to use parenthesis where perl's syntax doesn't require them, but that's just me. I find they frequently improve readability.


Information about American English usage here and here. Floating point issues? Please read this before posting. — emc


Comment on Re: filtering an array
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-08-01 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls