On Sunday 09 December 2007 17:05, Jeff Pang wrote:
>
> On Dec 10, 2007 6:23 AM, yitzle <[EMAIL PROTECTED]> wrote:
> >
> > Can the following code be done without any "code blocks"?
^
> > do {print "$_\n" if($_ > 3);} for (0..5);
> >
> > Thi
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 ty
On Dec 10, 2007 6:23 AM, yitzle <[EMAIL PROTECTED]> wrote:
> Can the following code be done without any "code blocks"?
> do {print "$_\n" if($_ > 3);} for (0..5);
>
> This doesn't work:
> print "$_\n" if($_ > 3) for (0..5);
>
$ perl -le 'print join" ",grep {$_>3} 0 ..5'
4 5
--
To unsubscribe, e-
On Sunday 09 December 2007 14:23, yitzle wrote:
>
> Can the following code be done without any "code blocks"?
> do {print "$_\n" if($_ > 3);} for (0..5);
$_ > 3 and print "$_\n" for 0 .. 5;
print map $_ > 3 ? "$_\n" : (), 0 .. 5;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-
Can the following code be done without any "code blocks"?
do {print "$_\n" if($_ > 3);} for (0..5);
This doesn't work:
print "$_\n" if($_ > 3) for (0..5);
In Python, you'd do something similar to:
print "$_\n" for (0..5) if($_ > 3);
but that doesn't work either.
If there a way to loop through a