in reply to my() troubles

To stay closer to your original example, try separating the 'my' statement from the value assignment:
sub input { my $input; # Just the 'my' here while ( 1 ) { $input = <STDIN>; # Asssignment here chomp ( $input ); if ( $input !~ /\d/ ) { print "ILLEGAL INPUT\n"; next; } last; } return $input; }

Now the scope of '$input' is the entire sub block and 'return $input;' will work.