in reply to Re: Passing logical operators on as content of scalar
in thread Passing logical operators on as content of scalar

print $number1, " is ", ("less than", "equal to", "greater than")[($number1 <=> $number2) ++ 1], " ", $number2, "\n";

Replies are listed 'Best First'.
Re^3: Passing logical operators on as content of scalar
by tybalt89 (Monsignor) on Feb 08, 2018 at 20:19 UTC
    print $number1, " is ", ("equal to", "greater than", "less than")[$number1 <=> $number2], " ", $number2, "\n";

    No need to add one :)

      I had thought about that, but decided that it would be easier to grasp without negative indices :-)

      Nice trick, but it calls for an explaining comment.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)