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.
In reply to Re: my() troubles
by dvergin
in thread my() troubles
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |