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