Perl s Function
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.
Following is the simple syntax for this function −
This function returns 0 on failure and number of substitutions made on success.
Following is the example code showing its basic usage −Live Demo
#!/usr/bin/perl -w $string = "This is Test"; # this will replcase Test with Best. $string =~ s/Test/Best/; print "$string\n";
When above code is executed, it produces the following result −
This is Best