How would you replace a char in string and how do you store
the number of replacements?
Answers were Sorted based on User's Feedback
Answer / tanu
$str='Hello';
$cnt= ($str=~s/l/i/g);
print $cnt;
$cnt stores the number of replacements.
| Is This Answer Correct ? | 20 Yes | 4 No |
Answer / 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 |
How to open a directory in perl?
what r the different type of function in perl ???
What are numeric operators in perl?
List the prefix dereferencer in Perl.
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
How do I sort a hash by the hash key?
what are prefix dereferencer and list them out?
What does init 5 and init 0 do?
How to code in perl to implement the tail function in unix?
What is the purpose of goto expr statement?
How does polymorphism work in perl?
Explain ivalue in perl?