my $string = "bob 299 frank 107 ted 300"; my %hash = split /\s+/, $string; foreach (keys %hash) { print "$_, $hash{$_}\n"; } #### my $file = "/home/andrew/data.txt"; my @array; open (FOO, $file) or die "can't open $file"; while () { @array = (@array, split /\s+/, $_); }; foreach (@array) { print "$_\n"; };