This doesn't answer the question (but it might) - looking at the code,
$_ is used clear down through the code and even across some sub routine calls. That takes a lot of faith that nobody else is manipulating
$_. Even if it doesn't fix the problem I would suggest using a named value rather than
$_. Example:
Instead of:
foreach (@misses)
Use:
foreach my $miss (@misses)
my @a=qw(random brilliant braindead); print $a[rand(@a)];