How would you replace a char in string and how do you store
the number of replacements?

Answer Posted / ananth_s

#!usr/bin/perl
use strict;
use warnings;
my $string="XmanXseriesx";
my $count = ($string =~ tr/X//);
print "There are $count Xs in the string\n";
print $string;

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?

542


Explain different types of perl operators.

535


What is the function of virtual documents in cgi programs?

522


What does the qq{ } operator do?

546


What is cpan in perl?

542






Mention what is cpan?

570


Explain the use of 'my' keyword in perl?

559


What are the different types of perl operators?

522


What is the difference between localtime() and gmtime() functions?

537


Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.

534


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

510


what are prefix dereferencer and list them out?

633


How to merge two arrays in perl?

517


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

553


Which has highest precedence in between list and terms? Explain?

434