use strict; use warnings; use feature 'say'; use Data::Dumper; my %hash; while () { chomp; my @items = split ','; $hash{ $items[0] } = $items[1]; } say Dumper \%hash; __DATA__ a,b a,c x,y #### $ perl 11132513.pl $VAR1 = { 'a' => 'c', 'x' => 'y' };