On Mon, 29 Mar 2010 10:02:15 -0400
Jeff Soules <[email protected]> wrote:
> ($foo == 1) ?
> $bar = 0 :
> $bar = 1;
> Am I doing something stupid or missing something obvious?
($foo == 1) ?
( $bar = 0 ) :
( $bar = 1 );
Assignment has lower precedence than ?: It is done last. What you
wrote above is:
(($foo == 1) ?
$bar = 0 :
$bar ) = 1;
Which assigns 1 to $bar regardless of what $foo is.
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/