> If you could give me an example of how I could do this I'm sure I could
> hack up the rest.
I'll go ahead and send this to the list.
You can call egrep from within perl to speed up and simplify the search.
$playerdir = "/path/to/player";
open(FILE, "egrep 'Clan|Levl|Cls' $playerdir/* |");
foreach (<FILE>) #for each line output
{
if ($_ =~ /Clan (.*)~$/) #if the line matches the pattern Clan X~
{$clans{$1}++;} #increment the count for that clan
if ($_ =~ /Cla (\d)$/)
{$class{$1}++;}
if ($_ =~ /Levl (\d+)$/)
{
$total_players++;
$total_levels+= $1;
}
}
close(FILE);
Now you have hashes %clans and %class that contain the player count for each
clan and class in them. Also, a $total_players variable and $total_levels
variable.
print "Total players: $total_players\n";
print "Average level of players: ".($total_levels/$total_players)."\n";
print "$class{0} mages.\n";
print "$class{1} clerics.\n";
print "$class{2} thieves.\n";
print "$class{3} warriors.\n";
foreach $cl (keys %clans)
{print "Clan $cl contains $clans{$cl} members.\n";}
--Palrich.