Skip to content
Related Articles

Related Articles

Perl | lt operator
  • Last Updated : 07 May, 2019
GeeksforGeeks - Summer Carnival Banner

lt‘ 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 the string to its right.

Syntax: String1 lt String2

Returns: 1 if left argument is less than the right argument

Example 1:




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



String1 is less than String2

Example 2:




#!/usr/local/bin/perl
  
# Initializing Strings
$a = "GeeksWelcome";
$b = "Geeks";
  
# Comparing the strings using lt operator
$c = $a lt $b;
  
if($c == 1)
{
    print"String1 is less than String2";
}
else
{
    print"String1 is not less than String2";
}
Output:
String1 is not less than String2

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :