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

Explain the meaning of subroutine?

953


Comment on data types and variables in perl.

899


How do I send e-mail from a Perl/CGI program on a Unix system?

992


What are the functions that can be performed using cgi program?

905


What are the different instances used in cgi overhead?

969


What's the difference between /^Foo/s and /^Foo/?

1163


What does the qx{ } operator do?

891


What are the two ways to get private values inside a subroutine?

878


List all the features of perl programming?

884


You want to read command-line arguements with perl. How would you do that?

877


What value is returned by a lone `return;’ statement?

1037


What is the use of strict?

906


what is Polymorphism in Perl?

944


Write syntax to use grep function?

948


What does file test operators do in perl?

895