|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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
}
?? |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > concatation (please slap me!!) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|