1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    I'm using the below statement and don't seem to be getting the results I expect. Basically, I have an order form which lets you choose your credit card type. You then submit the form values and a script does some checking and verifying with the form values. I would expect that if my credit card type is matched from the list, that the scalar return value should be 1. If it's not found, it should be 0. But in every case, grep returns 4, the number of values in my LIST. Why is this happening? Doesn't grep return the number of times a pattern was found in a list? I don't see what I'm doing wrong. Do I have a syntax problem? Any help would be appreciated. Thanks.
    $checker = grep $FORM{'PaymentMethod'}, ('Visa','Master Card','Amex','Discover');
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Rep Power
    grep is expecting an expression. this should work:

    $checker = grep /$FORM{'PaymentMethod'}/, ('Visa','Master Card','Amex','Discover');
  4. #3
  5. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Yes, that works. Thanks!

IMN logo majestic logo threadwatch logo seochat tools logo