>>> Consider, however, the confusion that would result from:
>>>
>>> tr/\s/\S/;
>>
>> Given a locale (or given utf8), there is a specific set of characters
>> matched by \s or \S. Consider them in order, and transliterate
>> appropriately.
>
> But you cannot transliterate a regex. That doesn't make sense. Use a
> regex operator for regexes. Use the transliterate operator for
> transliterations.
At the risk of prolonging this, I believe the idea is that we commonly
think of the regex metacharacters as sets, and we think of the arguments
to tr as ordered sets. And as long as we're not operating under the rules
of quantum computing, the set of characters represented by a regex
metacharacter *must* be ordered at some point, because we can't guarantee
that we test whether something is a space and a tab simultaneously. So
given an extremely useful collection of (ordered) sets with easy-to-type
names (i.e. the regex metacharacters), and an extremely rapid way of
transliterating members of one ordered set to members of another, why
shouldn't Perl allow us to use those things together? If I want to change
an input string by making all of its non-word characters into underscores,
I can currently use "s/[^a-zA-Z0-9_]/_/g;" or "tr/a-zA-Z0-9_/_/c;".
Personally, I'd be more likely to write "s/\W/_/g;", but only because I
can't use "tr/\W/_/;" or even "tr/\w/_/c;".
j