in reply to Array of array

use strict; use warnings; use Data::Dumper; my @kk = (["Hello","Perl"], ["Monks"]); foreach my $i(0..$#kk){ my @test = @{$kk[$i]}; print Dumper(\@test); }

Updated: Don't confuse with Data::Dumper, Do it like,

use strict; use warnings; my @kk = (["Hello","Perl"], ["Monks"]); foreach my $i(0..$#kk){ my @test = @{$kk[$i]}; }

Replies are listed 'Best First'.
Re^2: Array of array
by Kandankarunai (Novice) on May 05, 2011 at 06:34 UTC

    Thank you for ur help.The Data dumper returns $VAR1 value how assign it into normal array .Sorry for this type of question.I am new to perl

      In the example below, the elements of the  @kk array are already array references (i.e., scalar values). No need to dereference them to arrays and then copy them into anonymous array constructors to make them array references: just use them directly.

      >perl -wMstrict -le "use Data::Dumper; ;; my @kk = ( [ qw(aa bb cc dd) ], [ qw(kk jj ll mm) ], ); ;; my $i = 1; my $arrayref = $kk[ $i ]; ;; print Dumper $arrayref; print @$arrayref; " $VAR1 = [ 'kk', 'jj', 'll', 'mm' ]; kkjjllmm