my $str = 'a b c d e f g'; my ($key, $val) = split(/(?:\s+[^\s]+)+\s+/, $str); print "key=$key, val=$val\n";