Open In App

Perl | ge operator

Last Updated : 07 May, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

ge‘ 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 greater than or equal to the string to its right.

Syntax: String1 ge String2

Returns: 1 if left argument is greater than or equal to the right argument

Example 1: String1 is greater than String2




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


Output:

String1 is greater than or equal to String2

Example 2: String1 is equal to String2




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


Output:

String1 is greater than or equal to String2

Example 3: String1 is not greater than String2




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


Output:

String1 is not greater than or equal to String2


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads