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

Explain split function in perl?

635


Explain the internal working of cgi

598


Why to use perl?

618


What are scalar data and scalar variables?

703


What is eval function in perl?

612






How do I replace every TAB character in a file with a comma?

623


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

620


How does polymorphism work in perl?

594


What is the tk module?

663


For a situation in programming, how can you determine that Perl is a suitable?

555


What is the different between array and hash in perl programming?

582


What does redo statement do in perl?

635


You want to connect to sql server through perl. How would you do that?

611


Who created perl?

604


What is perl pop array function?

609