Write a script for 'count the no.of digits using regular
expressions in perl..
Answer Posted / rajendran
($test,$number) = ("","");
$test = "12344tyyyyy456";
@test=split('',$test);
foreach(@test)
{
if ($_ =~ /\d/)
{$number++;
}
}
print $number;
| Is This Answer Correct ? | 10 Yes | 3 No |
Post New Answer View All Answers
List the prefix dereferencer in Perl.
Why to use perl?
We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?
What is the purpose of “_file_ literal” and “_line_ literal” in perl?
What are the two ways to get private values inside a subroutine?
what are the three groups involved in information sharing?
What are some common methods to all handles in perl?
package MYCALC; use Exporter; our @EXPORT = (); our @ISA = qw(Exporter); our @EXPORT_OK = qw(addition multi); our %EXPORT_TAGS = (DEFAULT => [qw(&addition)],Both => [qw(&addition & +multi)]); sub addition { return $_[0] + $_[1]; } sub multi { return $_[0] * $_[1]; } 1; Program: use strict; use warnings; my @list = qw (2 2); use Module qw(:DEFAULT); print addition(@list),"\n"; Above coding is my module MYCALC and the program which using this module, I have not exported any function using @EXPORT, but I have used the DEFAULT in %EXPORT_TAGS with the function addition, when I call this function from the main it says the error as,
How many types of primary data structures in Perl and what do they mean?
How can we create perl programs in unix, windows nt, macintosh and os/2 ?
Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)
Explain ivalue?
Explain perl.
what is CPAN?
How do you you check the return code of a command in perl?