$string = "a=b c=d"; @array = split /(=)|\s/, $string; for ($i = 0; $i <= $#array; $i++) { splice(@array,$i,1) unless defined $array[$i]; }