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 is “grep” function in perl?

743


What is the difference between perl array and perl hash?

712


What is use of ‘->’ symbol?

747


Is perl compiler or interpreter?

716


How to close a file in perl?

690


Why do we use "use strict" in perl?

722


What are the various uses of perl?

708


Which has the highest precedence, List or Terms? Explain?

684


What are the reasons that cookie server can’t handle multiple connections?

728


What are the different string manipulation operators in perl?

704


What's the difference between /^Foo/s and /^Foo/?

755


How does a “grep” function perform?

775


If you want to empty an array then how would you do that?

772


What does the q{ } operator do?

670


How do I pass a command line argument in perl?

733