laziness, impatience, and hubris | |
PerlMonks |
Re: using map and anonymous subroutinesby flyingmoose (Priest) |
on Apr 20, 2004 at 13:36 UTC ( [id://346623]=note: print w/replies, xml ) | Need Help?? |
I love my map and anonymous subs! That's about the most fun part of Perl for me... :) Go go functional programming!
Essentially, i'm trying to take the values in an array, split them on white space, append a newline, and then store it all in another array
I'd do it like this:
edit: doh! dragon beat me to it (that's what I get for not reading responses first), but ah well at least I arrived at the exact same solution (I'm just overly explicit -- call it paranoia) so I guess it proves we are likely equally insane or something like that :)
If you want to remove things from that group, you use grepNot just that, but for those that don't know grep, it's also very nice for searching and counting! Essentially you are counting by removing all of the "non-hits" and then checking the scalar value of the array result, aka cardinality of the set. R0XX0R! (err, sorry, 1337 speak outbreak...)
In Section
Seekers of Perl Wisdom
|
|