Logical expressions work with the values true and false, and with operators that return the values true or false.
These expressions are used to modify the flow of statements. For instance, code can do one thing if two different variables have the same value, and something else if they variables do not have the same value. The numbers would be involved in a logical expression that is true if the numbers are even, and that expression is used in a statement that invokes code only on a true expression.
Perl does not have a literal true or false. However, every value is interpreted as either true of false when interpreted in a logical expression. In general, zero is false and everything else is true. For strings, zero means either the empty string or the string '0'. For numbers, zero is zero, simple as that.
» Try the given code to see what the value of "true" is. Modify something so that the expression evaluates to false, and see what the value of "false" is.
In the wide world of logical operators, the relational and equality operators compare numbers and strings for size equality, or inequality. Different operators are used for strings and for numbers. To compare numbers, == tests for equality, and != for inequality; < for strict less than, <= for less than or equal to, > for strict greater than, and >= for grater than or equal to.
Test for equality and assignment have different symbols, == versus =. Be careful not to confuse them.
To compare strings, "eq" tests for equality, "ne" for inequality; "lt", "le", "gt" and "ge" are the tests for inequality.
There is also "and" and "or" operations that will combine logical values. For instance, to test that a number is between 2 and 10, test that it is less than or equal to 10 "and" it is more than or equal to 2. The "and" operation is &&; the "or" operation is ||. Be careful, there are non-logical and and or operations, written with single characters & and |. These give different results.
» Let the variable $r be a three character string, representing a codon. Print "Coding for stop" if the string is a stop codon.
This is where the discussion goes. It's a long box underneath both the other boxes.