in reply to How can I change the perl program involving if-elsif-else conditional to get correct result?

if($a>$b>$c) is not the way you should think, this is erronous.

Write if($a>$b and $b>$c) instead, and correct all the other conditions as well. You should also consider filling a list with these values and sort them instead of this tiresome if-elsif-else method.

I'm too lazy to be proud of being impatient.
  • Comment on Re: How can I change the perl program involving if-elsif-else conditional to get correct result?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: How can I change the perl program involving if-elsif-else conditional to get correct result?
by eyepopslikeamosquito (Archbishop) on Apr 23, 2012 at 10:23 UTC

    if($a>$b>$c) is not the way you should think, this is erronous
    Though it may be "erronous" in Perl 5, I don't think it is erroneous in general. In fact, I think it is a sweet and natural syntax, aka "Chained Comparisons", and supported by both Perl 6 and Python.

      I omitted the "if you'd like to code correctly in Perl 5", yes, but I assumed that was the goal of the OP. :P "

      About chained comparisons: It's more natural than the current common practice, yes, but personally I don't find it nice. I never wrote a compiler, nor do I plan to, but I just don't think it's worth the trouble to implement it.

      Thank God, other people think otherwise, so in 2029 (my daughter graduates, Perl6 comes out) I'll be happy to get used to chained comparisons.

      I'm too lazy to be proud of being impatient.