use strict; my %hash=(); while (<>) { my ($num,$name)=(split/\s/,$_)[0,3]; $hash{$name}=$num; } foreach (keys %hash) { print "Key: $_\n"; print "Data: $hash{$_}\n"; }