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 are the different string manipulation operators in perl?

864


What is -> symbol in perl?

955


Write a program to decode the data in the form using cgi programming

983


List the prefix dereferencer in Perl.

877


Explain goto label?

865


What does cgi program store?

850


How to concatenate strings with perl?

797


How can you define “my” variables scope in Perl and how it is different from “local” variable scope?

1043


What can be done for efficient parameter passing in perl? Explain.

957


Comment on data types and variables in perl.

873


How do I sort a hash by the hash key?

870


how to get back up from private character editor which is saved in the format of .udf

2241


How do I replace every character in a file with a comma?

923


How to add elements in a hash in perl?

853


Explain socket programming in perl?

856