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


Please Help Members By Posting Answers For Below Questions

How can you create anonymous subroutines?

609


What is perl pop array function?

611


How to deleting an existing file in perl programming?

582


What is the difference between use and require in perl programming?

589


How to read a directory in perl?

613






What are arrays in perl?

635


How can you use Perl warnings and what is the importance to use them?

636


How to sort arrays in perl?

699


How to disable the mod_perl from apache_server as i have used perlfect search on the site and its pagination is not working and the remedy is to disable the mod_perl.

1874


What are the steps involved when the cgi program starts running?

584


How to renaming a file in perl programming?

625


What does a die() function do in perl?

645


Why Perl aliases are considered to be faster than references?

624


What are perl array functions?

617


How do you give functions private variables that retain their values between calls?

635