Stuart White <[EMAIL PROTECTED]> wrote:
:
: Couple things:
:
: About declaring variables in while loops and if
: constructs. I don't do that because it's messy and
: disorganized for me. I prefer to declare all the
: variables I will use in a subroutine at the top of the
: subroutine, before I write any assignments or process
: any code. It's just a style I prefer.
That's fine for a small program and for longer
ones I find objects and module eliminate many
variables. TIMTOWTDI. I do like to keep them in
the smallest scope possible though.
: What I want to return is the count of the number of
: fouls, nothing more. However, I am a bit lost as to
: how to count them. Can someone point me in the right
: direction to figure out how to count that?
my $fouls_count = 0;
open STATS, 'stats.txt' or die "Cannot open 'stats.txt': $!";
while ( <STATS> ) {
if ( /(\w+) Foul: (\w+)/ ) {
# $1 = player, $2 = foul type
print line_report( $1, $2 );
# count fouls
$fouls_count++;
}
}
close STATS;
print "\nTotal fouls: $fouls_count\n";
HTH,
Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]