Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Which functions in perl allows you to include a module file.

0 Answers  


How do I replace every TAB character in a file with a comma?

0 Answers  


Explain split function in perl?

0 Answers  


Who created perl?

0 Answers  


How can the user execute a long command repeatedly without typing it again and again?

0 Answers  


How does polymorphism work in perl? Give an example.

0 Answers  


Explain what is STDIN, STDOUT and STDERR?

0 Answers  


How can you replace the characters from a string and save the number of replacements?

0 Answers  


How many data types are there in perl?

0 Answers  


How can we create perl programs in unix, windows nt, macintosh and os/2 ?

0 Answers  


How to create a directory in perl?

0 Answers  


Is perl compiler or interpreter?

0 Answers  


Categories