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
Which functions in perl allows you to include a module file.
What is stdin in perl?
Difference between the variables in which chomp function work ?
What syntax is used for grep() function?
Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.
How to change a directory in perl?
Explain split function in perl?
Demonstrate subroutines in perl with a simple example.
“Perl regular expressions match the longest string possible”. What is the name of this match?
How to open a directory in perl?
What are scalar data and scalar variables?
What are the different instances used in cgi overhead?
Which has the highest precedence, List or Terms? Explain?
Define dynamic scoping.
How can memory be managed in Perl?