CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
&& in perl

 



rkr
New User

Feb 14, 2018, 12:10 AM

Post #1 of 2 (6399 views)
&& in perl Can't Post

I am new to perl.. could you please explain the relevance of && in this if statement.. what does that mean ?

elsif($rf1{$joint} > 1.0 && $rf > 1.05 && $rf < 1.5)

thanks


(This post was edited by rkr on Feb 14, 2018, 1:29 AM)


BillKSmith
Veteran

Feb 14, 2018, 7:44 AM

Post #2 of 2 (6390 views)
Re: [rkr] && in perl [In reply to] Can't Post

The short answer to your question is that your elsif is true only if all three of the 'greater than' expressions are true.

The '&&' is a 'logical and' operator. It returns a true value if both of its arguments are true (otherwise it returns a false value) In Perl, there are three values which are 'false' (undef, null string, and number 0). All other values are 'true'. In order to understand your statement, it necessary to also know that the '&&' operator has a lower precedence than the '>' operator. This means that the '>'s are evaluated before the '&&'s. The arguments for the first && are the results to the first two comparisons. The arguments of the second '&&' are the result of the first '&&' and the result of the third '>'.

You can use the perl documentation reader 'perldoc' to get the official explanation.
Learn to use the tool:

Code
perldoc perldoc

Read about the operators:

Code
perldoc perlop

Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives