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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

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


New User

Feb 14, 2018, 12:10 AM

Post #1 of 2 (6457 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)


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


Feb 14, 2018, 7:44 AM

Post #2 of 2 (6448 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:

perldoc perldoc

Read about the operators:

perldoc perlop

Good Luck,


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

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