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 |
What is the difference between die and exit in perl?
Explain lists in perl?
Which feature of perl provides code reusability?
How would you ensure the re-use and maximum readability of your perl code?
What is the purpose of redo statement?
how to connect cisco switch uisng perl script
In Perl, what is grep function used for?
Which feature of Perl provides code reusability ? Give any example of that feature.
Can you add two arrays together?
How do you match one letter in the current locale?
What is v-strings?
What is the purpose of goto expr statement?