Jump to content

Perl Programming/Keywords/and

From Wikibooks, open books for an open world
Previous: alarm Keywords Next: atan2

The and keyword

[edit | edit source]

and is a logical short-circuit AND operator that has a very low precedence, but is otherwise equivalent to &&.

Syntax

[edit | edit source]
  VALUE and VALUE

Examples

[edit | edit source]
The code
$a = 5; # 0101
$b = 8; # 1000

print $a and $b . ", " . $a && $b . "\n";
prints only the first variable, as it is not false:
5


Previous: alarm Keywords Next: atan2