Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL tr /// Function



Syntax

tr/SEARCHLIST/REPLACEMENTLIST/


Definition and Usage

This is not a function. This is the transliteration operator; it replaces all occurrences of the characters in SEARCHLIST with the characters in REPLACEMENTLIST.

Return Value

  • Number of characters replaced or deleted.

Example

#!/usr/bin/perl -w

$string = 'the cat sat on the mat.';
$string =~ tr/a-z/b/d;

print "$string\n";

It will produce following results: Here option d is used to delete matched characters

 b b   b.


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names