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 |
Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?
What is perl push array function?
What is the use of '>>' in perl?
How do you match one letter in the current locale?
How can you call a subroutine and identify a subroutine?
How do I read command-line arguments with Perl?
Explain the execution of a program in perl.
What are the steps involved in configuring a server using cgi programming?
Write a program to show the process of spawning a child process
Explain perl. What are the advantages of programming in perl?
what is perl language?
When would you not use Perl for a project?