It works for me, but it sounds like '[A-Z][a-z]+' might not be doing
what you think.

That says "One upper-case letter followed by one or more lower-case
letters."  I can see one problem with that right now.  I live in Santa
Clara, which won't match because it has a space in it.  But this
matched:

Santaclara, CA 95051

-----Original Message-----
From: Ryan Dillinger [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 20, 2006 5:17 PM
To: beginners@perl.org
Subject: print statement error

Hello All,
I have here a script, which all runs well with the exception of the:
print 
"value
looks like a city, state, and zip code.\n";. I can type in Upper or 
Lowercase letters in any
combination along with the zip, but I still get the error: "I couldn't 
figure out what that
value is. Can you please point out what's wrong with that line? Thanks
so 
much!

#!/usr/local/bin/perl
use warnings;

print "Enter a value and this program will try to guess what type of\n";
print "value it is. Enter 'q' by itself on a line to quit.\n";

while () {
    print "Enter a value: ";
    chomp($value = <STDIN>);

    if ($value =~ /^$/) {
        print "Please enter a value.\n";
        next;
    }

    last if ($value =~ /^q$/i);

    if ($value =~/^(male|female)$/i) {
        print "$value looks like a gender.\n";
        next;
    }

    if ($value =~ /^\d+\s[A-Z][\w\s]*$/) {
        print "$value looks like a street address.\n";
        next;
    }

    if ($value =~ /[EMAIL PROTECTED],4}$/) {
        print "$value looks like an email address.\n";
        next;
    }

    if ($value =~ /^[A-Z][a-z]+,\s[A-Z]{2}\s{1,2}\d{5}$/) {
        print "$value looks like a city, state, and zip code.\n";
        next;
    }

    if ($value =~ /^\W{0,1}\d{3}\W{0,1}\s{0,1}
                    \W{0,1}\s{0,1}\d{3}\s{0,1}\W{0,1}\s{0,1}\d{4}$/x) {
        print "$value looks like a telephone number.\n";
        next;
    }

    if ($value =~ /^perl$/i) {
        print "$value looks like the name of a programming language.\n";
        next;
    }

    print "I couldn't figure out what that value is.\n";
}

You Guy's are always a big help!!!



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




--
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