http://www.perlmonks.org?node_id=1016862


in reply to compare two strings and return only he unique values.

Note:

The various solutions posted above don't behave exactly the same. This is because the OP hasn't described the problem very precisely, so the commenters (myself included) have made implicit assumptions about the intended meaning of "unique values from two strings".

Interpreting the term "values" in that quote as characters, there are at least two different meanings:

If "values" is supposed to mean something other than individual characters, simply adapt any of the above solutions by replacing the split(//, ...) calls with a statement that tokenizes the string into a list of values in the intended way.

In case the strings are not intended to be tokenized in a fixed way, but instead what you are looking for is arbitrary text fragments that appear in one of the strings, but don't appear in that same spot in the other, look into Algorithm::Diff