use strict; use warnings; #grabs the line splits it into two parts and #puts in hash my %hash = map { (split /\|/,$_)[0,1] } ; #print the hash foreach (keys %hash) { print "$_, $hash{$_}",$/;} __DATA__ key1|value1| key2|value2| key3|value3|