Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL s/// Function



Syntax

s/PATTERN/REPLACE/


Definition and Usage

Not a function. This is the regular expression-substitution operator. Based on the regular expression specified in PATTERN, data is replaced by REPLACE. Like m//, the delimiters are defined by the first character following s.

Return Value

  • 0 on failure

  • Number of substitutions made on success

Example

#!/usr/bin/perl -w

$string = "This is Test";
# this will replcase Test with Best.
$string =~ s/Test/Best/;

print "$string\n";

It will produce following results:

This is Best


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names