December 2001
Intermediate to advanced
480 pages
9h 22m
English
Perl operators, for the most part, are identical to those in JavaScript, with some notable exceptions. First, numeric and string comparison operators are different. This difference can be very frustrating after using JavaScript because it’s easy to forget and use the wrong one. For example, the following script shows the correct way to use numeric and string operators:
$alpha="Apples";
$omega="Oranges";
if($alpha ne $omega) { #Uses a string comparison
print "They are different \n\n";
} The common error in Perl occurs when the programmer uses a line like this when both scalar variables are strings:
if($alpha != $omega) { #Wrong! So, when you write conditional statements in Perl, which are the same as in JavaScript, watch out ...
Read now
Unlock full access