Perl wrote:
I am trying to understand how this works. For example:

my $n = @$a > @$b ? @$a : @$b;


I understand this is a conditional statement I am just not sure what is
being compared with ? and :.

I believe that the above just assigns a true or false (1 or 0) to $n. The statement is the same as:


if(@$a > @$b) {
  $n = (@$a > @$a); # $n = 0 because @$a is not greater than itself
} else {
  $n = (@$a > @$b); # $n could be 1 or 0 depending on the values of @$a and @$b
}

I believe what you meant to do is:

my $n = (@$a > @$b) ? @$a : @$b;

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


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




Reply via email to