Transliteration, Not Substitution

For this next operator, the transliteration operator (sometimes called the translation operator), think back to how regular expression substitutions work: The substitution operator, which looks like s/pattern/replacement/ and was discussed in Hour 6, works against the $_ variable unless another scalar is specified with a binding operator =~. The transliteration operator works something like that, except that it doesn't use regular expressions and works completely differently. Still follow? The syntax for the transliteration operator is as follows:

tr/searchlist/replacementlist/

The transliteration operator—tr///—searches a string for the elements in searchlist and replaces them with the corresponding elements ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.