in reply to my() troubles

Instead of where you use "last;" You could use "return $input;" on that line or use the example below.
I wrote this replacement code
sub input { my $input; print "ILLEGAL INPUT $input\n" while ( chomp($input = <STDIN>) and $input !~ /^\d+$/); return $input; }
I changed it slightly in that it will only return input if $input is a number. Your example would return "spam9" as good input.