use strict; use warnings; use Data::Dumper; # Pretend that I've already read the file into @lines ... my @lines = ( 'A, B, C', 'D,E,F', 'G, H,I', ); # Zaxo's solution my %hash = map { chomp; split ',', $_, 2 } @lines; # View the data (use a *reference* to the hash, though!) printf "Data => %s\n", Dumper(\%hash); #### Data => $VAR1 = { 'A' => ' B, C', 'D' => 'E,F', 'G' => ' H,I' };