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 functions in perl allows you to include a module file.
How do I replace every TAB character in a file with a comma?
Explain split function in perl?
Who created perl?
How can the user execute a long command repeatedly without typing it again and again?
How does polymorphism work in perl? Give an example.
Explain what is STDIN, STDOUT and STDERR?
How can you replace the characters from a string and save the number of replacements?
How many data types are there in perl?
How can we create perl programs in unix, windows nt, macintosh and os/2 ?
How to create a directory in perl?
Is perl compiler or interpreter?