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 |
Which feature of perl provides code reusability?
How will you declare a variable in perl?
Explain goto name?
What are perl strings?
what are steps to do to lock the sony ericsson mobile with password?
Explain chop?
Demonstrate subroutines in perl with a simple example.
What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)
What is the use of '>>' in perl?
How do find the length of an array?
Explain chomp?
What are the various file operations in perl. Explain with example.