当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Perl gt用法及代码示例


'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


相关用法


注:本文由纯净天空筛选整理自Code_Mech大神的英文原创作品 Perl | gt operator。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。