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 |
Write the program to process a list of numbers.
There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"
Explain the meaning of closure in perl.
You want to add two arrays together. How would you do that?
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?
Which feature of perl provides code reusability?
What does -> symbol indicates in Perl?
Explain which feature of PERL provides code reusability?
What are the steps involved when the cgi program starts running?
What is chomp() operator/function?
We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?
How do I print the entire contents of an array with Perl?