當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Perl le用法及代碼示例


'' 運算符在珀爾是用於檢查兩個字符串是否相等的字符串比較運算符之一。它用於檢查其左側的字符串是否小於或等於其右側的字符串。

用法: String1 le String2

返回:如果左參數小於或等於右參數,則為 1

示例 1:String1 小於 String2


#!/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"; 
} 
輸出:
String1 is less than or equal to String2

示例 2:字符串 1 等於字符串 2


#!/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"; 
} 
輸出:
String1 is less than or equal to String2

示例 3:字符串 1 大於字符串 2


#!/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"; 
} 
輸出:
String1 is not less than or equal to String2


相關用法


注:本文由純淨天空篩選整理自Code_Mech大神的英文原創作品 Perl | le operator。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。