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 ...
####
my $msgformat = "You have obtained %d %s.\n";
if ($shotgobt) { printf $msgformat, $shotgobt, "shotguns") };
if ($armorobt) { printf $msgformat, $armorobt, "Armors") };
... do the same type of thing for the rest of the messages ...
####
my %stats = (
'clips' => 6,
'boxes of ammo' => 2,
'shells' => 47,
'boxes of shells' => 3,
'shotguns' => 2,
'Armors' => 2,
'health bonuses' => 1,
'medikits' => 4,
'stimpacks' => 2,
'yellow keycards' => 1,
'backpacks' => 1,
'berserk packs' => 1,
);
####
my $msgformat = "You have obtained %d %s.\n";
for my $stat (keys %stats) {
printf $msgformat, $stats{$stat}, $stat;
}