Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Passing logical operators on as content of scalar

by soonix (Monsignor)
on Feb 08, 2018 at 19:59 UTC ( #1208745=note: print w/replies, xml ) Need Help??


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 (Curate) 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". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1208745]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2018-02-25 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (312 votes). Check out past polls.

    Notices?