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 ...