#!/usr/bin/perl use strict; use warnings; print "\nPick a letter between a and d.\n"; chomp(my $reply = <STDIN>); while ($reply !~ /^[a-d]$/i) { print "Please enter only a letter between a and d.\n"; chomp($reply = <STDIN>); }
This code will stay in that while loop until it gets an acceptable response. A couple notes on how it works:
Hope this clears things up. Welcome to the monastery.
In reply to Re: do-while loop
by kennethk
in thread do-while loop
by irvson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |