$string = "a=b c=d"; @array = split /(=)|\s/, $string; foreach (@array) { $_ =~ s/\s(.*)/$1/; }