my @statement; ... my @structure; foreach (@statement) { ... push @structure , []; for (my $i=0;$i<= $#ex; $i++) { push @{ $structure->[$j]}, $ex[$i]; } }