How would you replace a char in string and how do you store
the number of replacements?
Answer Posted / tanu
$str='Hello';
$cnt= ($str=~s/l/i/g);
print $cnt;
$cnt stores the number of replacements.
| Is This Answer Correct ? | 20 Yes | 4 No |
Post New Answer View All Answers
Demonstrate subroutines in perl with a simple example.
What are the different string manipulation operators in perl?
Write an example explaining the use of symbol tables.
What do you mean by context of a subroutine?
What is a chop() function in perl?
How to remove a directory in perl?
What are arrays in perl?
In Perl, what is grep function used for?
How do I pass a command line argument in perl?
How will you create a file in perl?
Explain regular expression in perl?
What are the functions that can be performed using cgi program?
You want to print the contents of an entire array. How would you do that?
Explain grooving and shortening of arrays?
How to open a directory in perl?