Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old December 10th, 2000, 09:48 AM
tbonds
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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');

Reply With Quote
  #2  
Old December 14th, 2000, 01:53 PM
Dingle Dingle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 452 Dingle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 12 sec
Reputation Power: 8
grep is expecting an expression. this should work:

$checker = grep /$FORM{'PaymentMethod'}/, ('Visa','Master Card','Amex','Discover');

Reply With Quote
  #3  
Old December 14th, 2000, 09:39 PM
tbonds
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Yes, that works. Thanks!


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Grep function not working with FORM values?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway