You can enclose the logic in curlies to form a bare block and replace the exit with redo.
I'd prefer to organize the code refs as a real hash like so:
{ chomp (my $choice = <STDIN>); if (exists $codehash{$choice}) { &{$codehash{$choice}}; } else { print "ERROR: Please type in either 1, 2 or 3.\n"; redo; } }
After Compline,
Zaxo
In reply to Re: simple loop
by Zaxo
in thread simple loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |