Relational Operators

Learn all about relational operators in this lesson, especially the spaceship relational operator.

Basic operators

Comparison operators allow you to compare two values. The following table illustrates the different comparison operators in Perl:

Operator Name Example
== Equal a==b
!= Not Equal a!=b
< Less than a<b
> Greater than a>b
>= Greater than or equal to a>=b
<= Less than or equal to a<=b


Run the code snippet below to see how == and != work:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy