use strict; use warnings; my $a = 'a1:a2:a3=foo'; my ($key, $val) = split /=/, $a, 2; $key =~ s/:/}{/g; my %hash; eval "\$hash{$key}=\"$val\"";