Copyright © tutorialspoint.com

PERL y/// Function


Syntax

y/SEARCHLIST/REPLACEMENTLIST/


Definition and Usage

Identical to the tr/// operator; translates all characters in SEARCHLIST into the corresponding characters in REPLACEMENTLIST. It does character by character conversion

Return Value

  • Number of characters modified

Example

#!/usr/bin/perl -w

$string = 'the cat sat on the mat.';

# This will generate a upper case string
$string =~ y/a-z/A-Z/;

print "$string\n";

It will produce following results:

THE CAT SAT ON THE MAT.

Copyright © tutorialspoint.com