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 |
Explain the meaning of perl one-liner?
Explain cpan?
Explain USE and REQUIREMENT statements?
what is the procedure to define a user define module in your perl application?
What are scalar data and scalar variables?
what is the main function of fork() in cgi programming?
Is perl a case sensitive language?
How to concatenate strings in perl?
What is the different between array and hash in perl programming?
What is Perl?
What is epoch time in perl?
how to install a package in perl ????