Hi Everybody,
I'm having trouble figuring out the way the tertiary operator evaluates
and returns data. Here's what I don't get . . .
If I do this:
#!/usr/bin/perl -w
use strict;
my $num=3;
$num==3 ? print "Num equals 3" : print "Num does not equal 3";
I get what I'd expect, "Num equals 3" ge
[EMAIL PROTECTED]>
Sent: Monday, August 13, 2001 3:50 PM
Subject: Tertiary Operator Question
Hi Everybody,
I'm having trouble figuring out the way the tertiary operator evaluates
and returns data. Here's what I don't get . . .
If I do this:
#!/usr/bin/perl -w
use strict;
my $num
: "Paul Johnson" <[EMAIL PROTECTED]>
To: "David Rankin" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, August 13, 2001 4:09 PM
Subject: Re: Tertiary Operator Question
> On Mon, Aug 13, 2001 at 05:50:14PM -0400, David Rankin wrote:
>
> >
Thanks! I've been trying to figure that out for hours! Now I actually
get it!
-Dave
On Tue, 14 Aug 2001 00:09:59 +0200, Paul Johnson wrote:
>On Mon, Aug 13, 2001 at 05:50:14PM -0400, David Rankin wrote:
>
>> #!/usr/bin/perl -w
>> use strict;
>> my $num=3;
>> my $nextnum;
>> $num==3 ? $nextnu
On Mon, Aug 13, 2001 at 05:50:14PM -0400, David Rankin wrote:
> #!/usr/bin/perl -w
> use strict;
> my $num=3;
> my $nextnum;
> $num==3 ? $nextnum=4 : $nextnum="unknown" ;
> print $nextnum;
>
> It prints "unknown". I'd expect it to print "4" because $num==3 would
> evaluate to true.
You're bei