In Perl, you can use the eq
operator to compare two strings for equality.
In this example,
$str1
and $str2
with different values.eq
operator.eq
operator returns true
if the strings are equal, and false
otherwise.# Comparison of Strings in Perl using eq
my $str1 = 'Hello';
my $str2 = 'hello';
my $result = $str1 eq $str2;
print "Strings are equal: $result\n";
Strings are equal: false
In this tutorial, we learned How to Compare Two Strings in Perl language with well detailed examples.