数字运算符
、-、*、/、%、**、 、--、 =、-=、*=、/=
@a = (1 .. 4); # @a = (1,2,3,4),注:不能由大到小
$s = “Test”. 1; # $s = “Test1”
$s .= 2; #$s = “Test12”
@a = (1) x 4; # @a = (1,1,1,1)
$s = “A” x 4; # $s = “AAAA”
my ($a,$b) = (1,2); # my $a = 1; my $b =2;
$a=$b 1,$b=$a 1; # $a=$b 1;$b=$a 1;
($a,$b) = (1,2);
($a,$b) = ($b 1,$a 1); # $a=3, $b=2
# 不等于:$a=$b 1; $b=$a 1;
逻辑或:$a || $b 或$a or $b # a、b之一为真则为真
逻辑与:$a && $b 或$a and $b # a、b都为真时才为真
逻辑非:! $a 或not $a #a假时为真
逻辑异或:$a xor $b # a、b一真一假时为真
条件操作符(三目操作符):
条件?值1:值2,当条件为真时取值1,为假时取值2 ,如:
$result = ($var == 0) ? 14 : 7;