use strict; use warnings; my $savegame = 0; my $deathcnt = 0; ... then initialize the rest of your vars ... ... read the log file and accumulate the counts for each variable ...