push @structure , []; for (my $i=0;$i<= $#ex; $i++) { push @{ @structure->[$j]}, $ex[$i]; } #### foreach my $lev1 (@structure) { my $cnt = scalar(@{$lev1}; foreach my $lev2 (@{$lev1}) { my %hash = %{$lev2}; foreach my $key ( keys %hash ) { # if ($key eq $xx) etc. } } }