"Christopher L Hood" <[EMAIL PROTECTED]> wrote ... > Why doesn't this work to check the <STDIN> until it is one of the numbers > "1 2 3 4 5" ?? I have tried multiple variations of this with different > brackets ie. [ ] , and ( ) .
Chris, this doesn't work because you didn't write valid code. ;-) I think you probably wanted something like: foreach my $num(1 .. 5){ if ($type_number == $num) { # do something here last; } } > until($type_number == 1 .. 5 ){ I prefer to use grep() and avoid the foreach altogether (grep can be viewed as a version of foreach however): #!/usr/bin/perl use warnings; use strict; while (1) { print "Enter number: "; (my $input = <STDIN>) =~ s/\D//g; my ($found) = grep { $_ == $input } 1 .. 5; if ($found) { print "Found number $found!!!\n"; last; } else { print "Did not find a number between 1 and 5.\n"; } } Good luck, ZO -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>