Programming Languages C Subjective
Mar 15, 2013

If you are required to replace a char in a string and store the number of replacements. How would you do that?

Detailed Explanation

#!usr/bin/perl
use strict;
use warnings;
my $mainstring="APerlAReplAFunction";
my $count = ($mainstring =~ tr/A//);
print "There are $count As in the given string\n";
print $mainstring;

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback