How to count no of occurrence of a unique patterns in perl?
Answer Posted / perllearner
my %hshUniq;
my $testString = "This is the programme to check the count of unique values present in this text This is the programme to check";
my @arrList = split (" ",$testString);
foreach (@arrList);
{
chomp($_);
if ( exist %hshUniq{$_})
{
my $count = $hshUniq{$_};
$hshUniq{$_} = $count++;
}else
{
$hshUniq{$_} = 1;
}
}
while (($key,$value) = each(%hshUniq))
{
print "The unique character $key count in the string is $value
";
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the meaning of subroutine?
Comment on data types and variables in perl.
How do I send e-mail from a Perl/CGI program on a Unix system?
What are the functions that can be performed using cgi program?
What are the different instances used in cgi overhead?
What's the difference between /^Foo/s and /^Foo/?
What does the qx{ } operator do?
What are the two ways to get private values inside a subroutine?
List all the features of perl programming?
You want to read command-line arguements with perl. How would you do that?
What value is returned by a lone `return;’ statement?
What is the use of strict?
what is Polymorphism in Perl?
Write syntax to use grep function?
What does file test operators do in perl?