简体   繁体   中英

Size of 2D array in Perl

I need to get the size of the second level in a 2D array. I'm trying this:

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]);

But it doesn't work, and I see "ARRAY(0x804daf0)". How to get the size of the second dimension?

print scalar @{ $txt[1] }; should do the trick...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM