in reply to Calculating Total Different Array Terms On All Lines of Datafile
while (<DATA>) { chomp; ($family, $members) = split /=/, $_; @members = split /, /, $members; $total{$_}++ for @members; } for (sort keys %total) { print "$_ : $total{$_}\n"; } print '-'x20, "\nTotal: ", scalar keys %total; __DATA__ FLINTSTONES=BARNEY, FRED, WILMA JETSONS=MAX, TONY, WILMA SIMPSONS=LISA, BARNEY, WILMA, HOMER ALCATRAZ=ELIJAH, MAX, WILMA
|
|---|