See this tutorial for a comprehensive list.
Remember that “=” has to be used only to assign a value to a scalar. To compare two numbers we’ll use the ‘==’ operator, while to compare two strings the ‘eq’ operator.
This script is a shor example:
#!/usr/bin/perl $n1 = 10; $n2 = $n1; $n1++; if ($n1 == $n2) { print "Equal numbers: $n1 = $n2.\n"; } elsif ($n1>$n2) { print "$n1 is greater than $n2.\n"; } else { print "$n2 is greater than $n1.\n"; } |