my @elements = split / /, $string; my %hash = (@elements, (undef) x (@elements % 2));