Perl Programming/Keywords/tr

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: times Keywords Next: truncate

The tr keyword[edit | edit source]

tr is the transiteration operator and equivalent to y.

Syntax[edit | edit source]


Examples[edit | edit source]

The code
$tmp = "909135790159";

print $tmp . "\n";
$tmp =~ tr/13579/24680/;

print $tmp . "\n";
replaces the respective characters in the first parametre with the corresponding characters in the second parametre:

See also[edit | edit source]

Previous: times Keywords Next: truncate