use strict; use warnings; my %href; my $fn = <>; open(FH, "$fn") || die "Cannot open file"; while () { chomp($_); $href{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/; } while (my ($key, $value) = each(%href)) { print $key. ", ". $value."\n"; }