[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 ( ) .
> 
> 
> 
> until($type_number == 1 .. 5 ){
> 
        I know that you could use a character class [1-5] inconjunction with a 
regex:
                $type_number =~ /^\s*[1-5]\s*$/ 
        or you could predefine in a hash the valid inputs and check something 
like:

my %ValidInputs = qw ( 1 1 2 1 3 1 4 1 5 1);
my $type_number = '';

until($ValidInputs{$type_number}){

        Now if there are spaces before or after, it will still not be right.

        What you are really asking ( at least my my perspective in your 
statment is:
        $type_number == 1 or 2 or 3 or 4 or  5

        which under Perl is not valid.  You would have to tie the first part ( 
$type_number == ) with each or.  I know it would be nice, since Cobol can do 
this, why not Perl.  Maybe one of the Perl gurus can give us the why.

        There are a couple of ways to try.

Wags ;)  ps Use 'use strict and use warnings' makes life much easier if you 
start off that way.  Just a thought.

> print "Enter the number that corresponds to the type of offense you
> would like a report for\n";
> 
> print "1. Virus\n2.Spam\n3.Hacking\n4.Copyright\n5.Child
> Pornography\n"; 
> 
> chomp($type_number = <STDIN>);
> 
> }
> 
> 
> 
> 
> 
> Chris Hood



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to