sub namecount { my %count; open(INPUT, "$config::namedata"); # PULLS NAMES FROM FLAT FILE open(OUTPUT, ">$config::namecountdata"); # PUTS NAME COUNT IN NEW FILE my $namecnt='David|Tom|Sam|Will|Dave|William|Thomas'; while(){ my @words = split(":"); foreach my $word (@words){ if($word=~/($namecnt)/io){ $count{$1}++; } } } foreach my $word (sort keys %count) { printf("%39s %-14s %-19s %6s", colored("There are",'cyan bold'), colored("$count{$word}",'yellow bold'), colored("$word",'cyan bold'), colored("Name(s)\n",'cyan bold') ); print OUTPUT "There are $count{$word} $word Name(s)\n"; } close INPUT; close OUTPUT; } # END SUB