Perl Programming/Keywords/y
< Perl Programming | Keywords
The y keyword
[edit | edit source]y is the transiteration operator as known from the UNIX sed line editor, and is equivalent to tr.
Syntax
[edit | edit source] y///
Examples
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Crystal_Clear_action_apply.png/20px-Crystal_Clear_action_apply.png)
$tmp = "909135790159";
print $tmp . "\n";
$tmp =~ y/13579/24680/;
print $tmp . "\n";
replaces the respective characters in the first parametre with the corresponding characters in the second parametre:
909135790159 000246800260