Operators
4.1 Numeric vs String Operators
Greater or equal Compare (-1, 0, 1) <=> ("spaceship") Use the right operator! "abc" == "xyz" is true (both are 0 numerically, with a warning). 10 lt 9 is true (string comparison).
4.2 Other Operators
+ - * / % **, unary - . (concatenate), x (repeat) = += -= *= /=.= x= **= %= //= ||= &&=
++ -- (magic string increment: 'aa'++ → 'ab', 'Az' → 'Ba', 'zz' → 'aaa')
&& || ! and low-precedence and or not xor cond ? a: b .. (1..10, 'a'..'e'), flip-flop in scalar context
& | ^ ~ << >> (and string-bitwise &. |. ^. ~. with the bitwise feature) =~ and !~ (regex)
-e -f -d -r -w -x -s -z -M -l and more Comma / fat comma , and => (auto-quotes the left side) -> (dereference, method call)
isa (5.32+, stable in 5.36): $obj isa My::Class 1 < $x < 10 (5.32+)
open(my $fh, '<', $file) or die "Can't open $file: $!"; # low-precedence `or` for control flow
my $result = $value || 'default'; # high-precedence || for values
say "In range" if 1 <= $n <= 100; # chained comparison4.3 Precedence Highlights
or/and/not have the lowest precedence. Use them for control flow (open ... or die).
|| binds tighter than =, so my $x = $a || $b; works, but open my $fh, '<', $f || die is wrong (the || binds to $f).
When in doubt, add parentheses. perldoc perlop has the full precedence table.