in reply to Advice on goto usage?
INPUT: { print("Type R to re-enter the values or Type E to exit:\n"); chomp( my $value = <STDIN> ); if ( $value eq 'E' ) { exit; } if ( $value ne 'R' ) { print("Invalid entry, try again:\n"); } redo INPUT; }
This is a bare-block with redo. You can also use next and last (which are synonymous in a bare-block) to leave the block and continue processing at the first line after the block. This is not considered 'goto' because redo/next/last are forced to work within either the innermost loop/bare block or with labelled loop/bare blocks. You can't redo to a labelled line, like you can with goto.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Advice on goto usage?
by tlm (Prior) on May 05, 2005 at 14:01 UTC |