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
What are the different string manipulation operators in perl?
What is -> symbol in perl?
Write a program to decode the data in the form using cgi programming
List the prefix dereferencer in Perl.
Explain goto label?
What does cgi program store?
How to concatenate strings with perl?
How can you define “my” variables scope in Perl and how it is different from “local” variable scope?
What can be done for efficient parameter passing in perl? Explain.
Comment on data types and variables in perl.
How do I sort a hash by the hash key?
how to get back up from private character editor which is saved in the format of .udf
How do I replace every character in a file with a comma?
How to add elements in a hash in perl?
Explain socket programming in perl?