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:
  #1  
Old April 20th, 2001, 10:29 AM
randor randor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Western New York
Posts: 85 randor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 8 m 46 sec
Reputation Power: 8
Send a message via Yahoo to randor
hello,

ok, i am completly drawing a blank on this, and i know that i should know it.. but, i have sent a field to my script like this: $field{'option1'} $field{'option2'} $field{'option3'} ect... and what i need to do is to check each field to see if they have a value in them.. but for the life of me, i cannot remember how to properly concatate this so that i can do it all in 1 if statement. the only thing that i can come up with, which i know isnt right is this:

$i = '1'; ##start the count at 1
while ($i != '10') { ##run through all options
if ($field{'option.$i'}) {print "yes on field $i\n"} ##if they match then let me know
$i++; ##autoincriment
} ##closeout the while statement

thank you for helping me jar my frail memory..
Randor

Reply With Quote
  #2  
Old April 20th, 2001, 11:27 AM
randor randor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Western New York
Posts: 85 randor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 8 m 46 sec
Reputation Power: 8
Send a message via Yahoo to randor
i got it..

sorry, i figured it out.. the answer is:

$i = '1'; ##start the count at 1
while ($i != '10') {##run through all options
$option = 'option'.$i; ##add it together
if ($field{"$option"}) {print "yes on field $i\n"} ##if they match then let me know
$i++; ##autoincriment
} ##closeout the while statement


thank you anyway..

Randor

Reply With Quote
  #3  
Old April 20th, 2001, 02:17 PM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
just a question, but why not do:

Code:
foreach $key ( keys %fields ) {
 if($fields{$key}) {print "yes on field $i\n"} ##if they match then let me know 
}

??

Reply With Quote
  #4  
Old April 20th, 2001, 02:53 PM
randor randor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: Western New York
Posts: 85 randor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 8 m 46 sec
Reputation Power: 8
Send a message via Yahoo to randor
unobserved,

yes, normally that wouldwork, but not only do i have the previosly shown in the hash, but also calls that i do not need, such as $field{'stat'}, so i only need the selected ones,

but thank you
Randor

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > concatation (please slap me!!)


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 3 hosted by Hostway