Perl's Function



Description

This is 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.

Syntax

 s/PATTERN/REPLACE/ 

Example

Following is the example code showing its basic usage −

 #!/usr/bin/perl -w $string = "This is Test"; # this will replace Test with Best. $string =~ s/Test/Best/; print "$string\n"; 

When above code is executed, it produces the following result −

 This is Best 
perl_function_references.htm
Advertisements