c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @lines = ( 'foo: 12 : //comment twelve ', 'bar: 13 : //comment thirteen', 'foo: 5 : //comment five', ); ;; my %hash; for my $line (@lines) { my ($k, $v) = split qr{ : \s+ }xms, $line, 2; push @{ $hash{$k} }, $v; } dd \%hash; " { bar => ["13 : //comment thirteen"], foo => ["12 : //comment twelve ", "5 : //comment five"], }