my ($type, $restofstring) = /^type=(\w+) (.+)$/; for $restofstring (split) { my ($key, $val) = split /=/, $restofstring; $hash{$type}{$key} = $val; }