file's data: 010 011 012 020 021 #### code: ... my $line_num=1; my $hash; while () { chomp $_; my $line = $_; my @array = map { s/^\s+//; # strip leading spaces s/\s+$//; # strip tailing spaces $_ # return the modified string } split '\s+', $line; print $array[0]."\n"; # WORKS print $array[1]."\n"; # WORKS print @array."\n"; # prints number of elements instead of whole array $hash->{$line_num}=@array; # does not works because of previous issue $line_num++; }