It's pretty cool notation, actually...

Thanks for the responses.

- B
__________________


$a ? $b : $c;
is the same as

if( $a ){
     $b
} else {
     $c
}

see perldoc perlop (I think)
but I would have put the foreach in front for readability:
foreach (@your_list) { $_ % 2 ? print "blue\n" : print "red\n" }

> -----Original Message-----
> From: Bryan R Harris [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 1:52 PM
> To: [EMAIL PROTECTED]
> Subject: Re: probably a simple question
>
>
>
>
> > $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list);
>
>
> This actually works?!  Very strange notation, how does the
> compiler see
> this line?  I assume the mod operator evaluates to 1-true or
> 0-false, what
> does the "?" do?  What does the ":" do?  How do you have a
> foreach at the
> end of a line like that?
>
> Why do I get the feeling I'm never going to graduate from
> this list...  =)
>
> - B
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

----------------------------------------------------------------------------

--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to