before calling the second for loop just try use Data::Dumper; print Dumper \@a;