1 ```perl 2 #!/usr/bin/perl 3 4 use strict; 5 use warnings; 6 7 my @arr; 8 9 foreach(1..4) 10 { 11 push @arr,[0,0,0,0]; 12 } 13 my ($i,$j); 14 15 for($i=0;$i<5;$i++) 16 { 17 for($j=0;$j<5;$j++) 18 { 19 print "$arr[$i][$j] "; 20 } 21 } 22 23 #push @arr,[(0) x 4]foreach 1..4 24 25 my $change=3;my $b=4; 26 27 $change=$b==0 ? 'first':'end';print "$change=$change,$b=$b "; 28 29 #$change=end,$b=4 30 31 my $n = '';$n = $n-2;print "$n "; 32 33 #-2 34 35 my $m = 0;$n = $m == 0? 'null == 0':'null != 0';print "$n "; 36 37 ```
建立二维数组方式二:
1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 my @arr=qw/ A B C D /; 7 my @multiarr ;push @multiarr,[@arr]; 8 print "$multiarr[0][0] "; 9 10 11 #A