my $string = "bob 299 frank 107 ted 300"; my %hash = split /\s+/, $string; foreach (keys %hash) { print "$_, $hash{$_}\n"; }