$ perl use strict; use warnings; use Data::Dumper; my $string="1:one;2:two;3:three"; my %hash; my @list1 = split /;/, $string; foreach my $item(@list1) { my ($i,$j)= split(/:/, $item); $hash{$i} = $j; } print Dumper \%hash; __END__ $VAR1 = { '1' => 'one', '3' => 'three', '2' => 'two' }; $