my @array = split /\s/, $string; for my $i (reverse 0 .. $#array) { $array[$i] = splice @array, $i, 1, split(/(=)/, $array[$i]); }