Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Perl | eq operator

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

eq‘ operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise equal to the string to its right.

Syntax: String1 eq String2

Returns: 1 if left argument is equal to the right argument

Example 1:




#!/usr/local/bin/perl
  
# Initializing Strings
$a = "Welcome";
$b = "Geeks";
  
# Comparing the strings using eq operator
$c = $a eq $b;
  
if($c == 1)
{
    print"String1 is equal to String2";
}
else
{
    print"String1 is not equal to String2";
}

Output:

String1 is not equal to String2

Example 2:




#!/usr/local/bin/perl
  
# Initializing Strings
$a = "Geeks";
$b = "Geeks";
  
# Comparing the strings using eq operator
$c = $a eq $b;
  
if($c == 1)
{
    print"String1 is equal to String2";
}
else
{
    print"String1 is not equal to String2";
}

Output:

String1 is equal to String2

My Personal Notes arrow_drop_up
Last Updated : 07 May, 2019
Like Article
Save Article
Similar Reads