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 |
Is perl a case sensitive language?
Define print() function in perl?
How would you replace a char in string and how do you store the number of replacements?
What does a die() function do in perl?
What does cgi program store?
Enlist the advantages of using c over perl?
What elements of the Perl language could you use to structure your code to allow for maximum re-use and maximum readability?
Which of these is a difference between Perl and C++ ?
What are stdin, stdout and stderr?
What does localtime() do in perl?
How to sort arrays in perl?
Write a program to show the process of spawning a child process