my @arr; open (B, "temp.dat"); while (my $line=) { chomp $line; $line =~ s/\s//g; my @temp = split //, $line; push @arr, [@temp]; }