Perl gt运算符
Perl中的 ‘gt ‘运算符是字符串比较运算符之一,用于检查两个字符串是否相等。它用于检查其左边的字符串是否大于其右边的字符串。
语法: String1 lt String2
返回: 如果左边的参数大于右边的参数,则 返回 1。
例1 :
#!/usr/local/bin/perl
# Initializing Strings
a = "Welcome";b = "Geeks";
# Comparing the strings using gt operator
c =a gt b;
if(c == 1)
{
print"String1 is greater than String2";
}
else
{
print"String1 is not greater than String2";
}
输出。
String1 is greater than String2
例2 :
#!/usr/local/bin/perl
# Initializing Strings
a = "Geeks";b = "GeeksWelcome";
# Comparing the strings using gt operator
c =a gt b;
if(c == 1)
{
print"String1 is greater than String2";
}
else
{
print"String1 is not greater than String2";
}
输出。
String1 is not greater than String2