y/// Operator in Perl

What is y/// Operator in Perl?

Explanation

The y/// Operator is used to transliterate string.

Syntax:


y/search list/replace list/options;

In the above syntax, "search list" is the string to be searched for, "replace list" is the string to be replaced, "options" are optional arguments.

Example :


#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
$string = 'maurice mike is the father of morris mike';
$string =~ y/abcde/ABCDE/;
print $string;
Result :

mAuriCE mikE is thE fAthEr of morris mikE

In the above y/// Operator for transliterate string example the smaller case string "abcde" is replaced with uppercase "ABCDE" in the string.

Ask Questions

Ask Question