Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl中2D数组的大小_Perl_Multidimensional Array - Fatal编程技术网

Perl中2D数组的大小

Perl中2D数组的大小,perl,multidimensional-array,Perl,Multidimensional Array,我需要得到2D数组中第二层的大小。我正在尝试这个: my @txt; $txt[0][0]="text1"; $txt[0][1]="text2"; $txt[0][2]="text3"; $txt[1][0]="text4"; $txt[1][1]="text5"; $txt[1][2]="text6"; print scalar(@txt[1]); 但它不起作用,我看到了“数组(0x804daf0)”。如何获得第二维度的大小?print scalar@{$txt[1]}应该这样做…这给

我需要得到2D数组中第二层的大小。我正在尝试这个:

my @txt;
$txt[0][0]="text1";
$txt[0][1]="text2";
$txt[0][2]="text3";

$txt[1][0]="text4";
$txt[1][1]="text5";
$txt[1][2]="text6";

print scalar(@txt[1]);

但它不起作用,我看到了“数组(0x804daf0)”。如何获得第二维度的大小?

print scalar@{$txt[1]}应该这样做…

这给出了行的长度,您知道如何获得列的长度吗?