Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What does a die() function do in perl?

1034


Give an example of using the -n and -p option.

1064


How to merge two arrays in perl?

1112


What is the difference between use and require in perl programming?

987


What is the closure in PERL?

1069


Is perl compiler or interpreter?

983


Write syntax to use grep function?

1018


What is the difference between perl array and perl hash?

1174


What are different data types that perl supports. Elaborate on them.

1175


What are the different types of perl operators?

1153


what is Chop & Chomp function does?

1040


Explain goto name?

981


What does Perl do if you try to exploit the execve(2) race involving setuid scripts?

996


Perl regular expressions are greedy" what does this mean?

968


How to copy a file in perl?

1053