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


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