Question:

How can you replace the characters from a string and save the number of replacements?

Answer:

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

 


Keywords:

© 2017 QuizBucket.org