Thanks for the replies!

On 12/9/07, John W. Krahn <[EMAIL PROTECTED]> wrote:
> $_ > 3 and print "$_\n" for 0 .. 5;

This one instantly appealed to me for some reason. I love it!
Reminds me of the Python version of the if operator (? :).
(I started reading Dive Into Python this last week. Strong typing? *shudder*)

> print map $_ > 3 ? "$_\n" : (), 0 .. 5;

I've got to learn to use map, but the if operator (or whatever its
named) if of limited use. It works for this specific case but does not
allow more complex operations. I'm not sure how much can be
accomplished with map.


On 12/9/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
> $ perl -le 'print join" ",grep {$_>3} 0 ..5'

This solution is versatile [1], but the thought of looping through the
array twice makes me... unhappy. I know. Perl is a scripting language
and C will give better performance and in 99.99% cases the performance
difference will never be noticed, but I still feel that way. ;)

[1] perl -e 'print "$_\n" for (grep {$_ > 3} (0..5) );'

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


Reply via email to