my $string5="13.7ff44"; print $string4 + $string5, "\n"; print $string4 * 5, "\n"; my $num1=55; my $string6="55"; if ( $num1 eq $string6 ) { print "equal", "\n"; } else { print "not equal", "\n"; } my $num2=55.5; my $string7="55.5"; if ( $num2 ...
say 'the strings are not equal'; } The example compares two strings. $ ./comparison.pl the strings are not equal Perl string repeat Thexoperator repeats the given string. comparison.pl #!/usr/bin/perl use 5.30.0; use warnings; say 'falcon ' x 4; The example repeats the specified str...
# q operator creates a single-quoted string with any delimiter$q_string=q/This is a 'single-quoted' string/;print$q_string;# prints This is a 'single-quoted' string# qq operator creates a double-quoted string with any delimiter$qq_string=qq(This is a "double-quoted" string with variable...
# 对于字符串的相等,只能用eq (equal) 和 ne (not equal)。 } else { # 嗯,else还是和其他语言类似的 } foreach循环 # foreach循环其实有两种套路 # 普通的 my @arr = (a , b , c); foreach my $elem (@arr) { # 注意:my的使用,因为$elem前面没定义, # 所以这里必须定义用my。 # 其次,...
if($var==1){print"scalar";}elsif{$vareq'abc'}{#使用elsif,而不是elseifprint "string" }else{print'other';} 6|2三目运算符?: #和verilog的三目运算符一致my$name='Lisa';my$age='20';my$status= ($age>40) ?"is me":"not me";print"$name - $status\n"; ...
Binary "eq" returns true if the left argument is stringwise equal to the right argument. Binary "ne" returns true if the left argument is stringwise not equal to the right argument. Binary "cmp" returns -1, 0, or 1 depending on whether the left argument is stringwise less than, ...
The right operand is not evaluated while the operator is in the "false" state, and the left operand is not evaluated while the operator is in the "true" state. The precedence is a little lower than || and &&. The value returned is either the empty string for false, or a sequence nu...
eq: Theequaloperator checks if the given string matches another string. It returns true if there’s a match, otherwise false. ne: Thenotequal operator is the reverse ofeq. It returns false if there’s a match, otherwise true. Example: Checking for Empty String usingeqOperator ...
or "not" returns a special false value. When evaluated as a string it is treated as '', but as a number, it is treated as 0. Statement Modifiers Any simple statement may optionally be followed by a SINGLE modifier, just before the terminating semicolon (or block ending). The possible ...
or not returns a special false value. When evaluated as a string it is treated as "" , but as a number, it is treated as 0. Most Perl operators that return true or false behave this way. Statement Modifiers Any simple statement may optionally be followed by a SINGLE modifier, just ...