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 is cpan ? What are the modules coming under this?
Explain lists ?
What is the use of 'ne' operator?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
How many data types are there in perl?
For a situation in programming, how can you determine that Perl is a suitable?
Give an example of the -i and 0s option usage.
What does this symbol mean '->'?
What is hash?
Why do you use Perl?
What are the different types of perl operators?
Write syntax to use grep function?
how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.
How do you set environment variables in perl?
You want to add two arrays together. How would you do that?