|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
grep is expecting an expression. this should work:
$checker = grep /$FORM{'PaymentMethod'}/, ('Visa','Master Card','Amex','Discover'); |
|
#3
|
|||
|
|||
|
Yes, that works. Thanks!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Grep function not working with FORM values? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|