Open In App

Perl | le operator

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
'le' 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 less than or equal to the string to its right.
Syntax: String1 le String2 Returns: 1 if left argument is less than or equal to the right argument
Example 1: String1 is less than String2 Perl
#!/usr/local/bin/perl

# Initializing Strings
$a = "Geeks";
$b = "Welcome";

# Comparing the strings using le operator
$c = $a le $b;

if($c == 1)
{
    print"String1 is less than or equal to String2";
}
else
{
    print"String1 is not less than or equal to String2";
}
Output:
String1 is less than or equal to String2
Example 2: String1 is equal to String2 Perl
#!/usr/local/bin/perl

# Initializing Strings
$a = "Geeks";
$b = "Geeks";

# Comparing the strings using le operator
$c = $a le $b;

if($c == 1)
{
    print"String1 is less than or equal to String2";
}
else
{
    print"String1 is not less than or equal to String2";
}
Output:
String1 is less than or equal to String2
Example 3: String1 is greater than String2 Perl
#!/usr/local/bin/perl

# Initializing Strings
$a = "GeeksWelcome";
$b = "Geeks";

# Comparing the strings using le operator
$c = $a le $b;

if($c == 1)
{
    print"String1 is less than or equal to String2";
}
else
{
    print"String1 is not less than or equal to String2";
}
Output:
String1 is not less than or equal to String2

Similar Reads