for my $pair ( split /\s+/, $restofstring ) { my ($key, $val) = split /=/, $pair; $hash{$type}{$key} = $val; }