sdslrn123 has asked for the wisdom of the Perl Monks concerning the following question:
I know how to calculate the total number of terms. But, how do I calculate the total number of different terms?FLINTSTONES=BARNEY, FRED, WILMA JETSONS=MAX, TONY, WILMA SIMPSONS=LISA, BARNEY, WILMA, HOMER ALCATRAZ=ELIJAH, MAX, WILMA
while(<DATA>) { chomp; my ($family, $people) = split /--/, $_, 2; #split + into two: family and memebers my @members = split /,\s* +/, $people, -1; #split family line into an array foreach my $member (@members) { #foreac +h member within array push @{$people{$member}}, $family; #push i +nto an array $families{$family}++; my $total_families = scalar(keys %families);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calculating Total Different Array Terms On All Lines of Datafile
by GrandFather (Saint) on Jun 25, 2006 at 23:49 UTC | |
|
Re: Calculating Total Different Array Terms On All Lines of Datafile
by shmem (Chancellor) on Jun 25, 2006 at 23:26 UTC | |
|
Re: Calculating Total Different Array Terms On All Lines of Datafile
by TedPride (Priest) on Jun 25, 2006 at 23:25 UTC | |
|
Re: Calculating Total Different Array Terms On All Lines of Datafile
by rsriram (Hermit) on Jun 26, 2006 at 07:00 UTC |