From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Relational operators - Perl Tutorial
From the course: Perl 5 Essential Training
Relational operators
- [Voiceover] The relational operators are used to compare values in a logical context. Here's a working copy of relational.pl from chapter eight of the exercise files. Relational operators return a value of true or false. Now in Perl, anything that is empty or zero is considered false and anything else is considered true. In general, the relational operators will return the number one for true and an empty string for false. These operators are typically used in conditional context. For example, in this if statement here on line 12, if $a is equal to $b. Now this is the relational operator that tests for numeric equality. It works for numbers, and it does not work for strings. So testing of $a equals $b, of course $a is 7 and $b is 42. So if I run this, I will get the result that says false. And if I change this to say if $a equals $c which is also 7 like $a and I run it, then it says true. Now some of these relational operators include the not equal to. So I can run that, and now…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
About Perl's operators2m 35s
-
(Locked)
Basic arithmetic operators5m 30s
-
(Locked)
Compound assignment operators2m 5s
-
(Locked)
Relational operators3m 27s
-
(Locked)
Logical operators6m 1s
-
(Locked)
File test operators3m 42s
-
(Locked)
The range operator2m 54s
-
(Locked)
The string concatenation operator1m 31s
-
(Locked)
Quote operators4m
-
(Locked)
-
-
-
-
-
-
-
-