use strict; use warnings; use Data::Dumper; my $string = "1:one;2:two;3:three"; my %hash = split /[;:]/, $string; print Dumper \%hash; #### $VAR1 = { '1' => 'one', '3' => 'three', '2' => 'two' };