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



How would you replace a char in string and how do you store the number of replacements? ..

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

How would you replace a char in string and how do you store the number of replacements? ..

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

Post New Answer

More CGI Perl Interview Questions

What is perl I used for?

0 Answers  


What does this symbol mean '->'?

0 Answers  


What is lexical variable in perl?

0 Answers  


what is perl language?

0 Answers  


What is the function of cgiwrap in cgi programming?

0 Answers  






You want to concatenate strings with perl. How would you do that?

0 Answers  


Enlist the advantages of using c over perl?

0 Answers  


write a perl script to find whether a given line of text is starting and ending with same word or not ???

2 Answers   CSS,


What value is returned by a lone `return;’ statement?

0 Answers  


What is perl scripting?

0 Answers  


Write an example explaining the use of symbol tables.

0 Answers  


Create a function that is only available inside the scope where it is defined ?

0 Answers  


Categories