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 what is the scalar data and scalar variables in Perl?
what are the strategies followed for multiple form interaction in cgi programs?
What are some common methods to all handles in perl?
What are the purpose of close(), getc() and read() functions?
What is the peculiarity of returning values by subroutines in perl?
Name an instance where you used a CPAN module?
Explain perl. What are the advantages of programming in perl?
what are the three groups involved in information sharing?
Why -w argument is used with perl programs?
what is the function of Return Value?
what is the function that is used to identify how many characters are there in a string?
Does Perl have reference type?