BArtWell
BArtWell

Reputation: 4044

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?

Upvotes: 5

Views: 8604

Answers (1)

pavel
pavel

Reputation: 3498

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

Upvotes: 10

Related Questions