|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
|
So first off, I have never taken a lesson in C or perl, but am pretty good with most computer languages
I have come up with a stumbling block in a perl script that I am working on, in particular checking for equality in a string value, and am looking for help I have a simple form with user choices 1; value = 'nochoice' 1; value = 'yes' 1; value = 'no' form input is parsed and handed to the subroutine if ($value ne "nochoice") {$modifyfield = 26; $searchtext eq $value;} which did not find true upon any value other than 'nochoice' (in otherwords i want the true value to function, on a choice of yes or no so I added $value =~ /$value/i ; before the if statement to try and clean up any possible erroneous charactures or whatever, but it's still not working what am i doing wrong, any ideas (if this doesn't display in the forum, I'll try an imagelink) |
|
|
|
|
|
#2 |
|
Confirmed User
Join Date: Dec 2001
Location: Malibu
Posts: 3,817
|
Well...
if ($value ne "nochoice") {$modifyfield = 26; $searchtext eq $value;} If you want $searchtext to be come equal to $value, you should use '$searchtext = $value' instead of '$searchtext eq $value'. About the non trueing, what I would try is, try each value out and let the script print $value, or something like: 'print "x".$value."x"', so whatever is between the x's is the actual value of $value (so you're not missing any spaces and stuff), because maybe the =~ didn't clean up, and so you will end up seeing $value was actually '%nochoice', or something. If printing and checking the $value still doesn't give any results, then instead of 'if ($value ne "nochoice")' try the following: 'if ($value !~ m/nochoice/)'. |
|
|
|
|
|
#3 |
|
Macdaddy coder
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
|
hit me up ...
__________________
MacDaddy Coder. |
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
|
Thanks for your suggestion Fugalot , I'll play with it
the form input is multiple select, so the user cannot type in any variations, but I'll try what you're suggesting thanks for the offer boldy, but I don't use icq 99% of the time I am going to break down the script to a single program and run the subroutine only to see it I can sort it out maybe it's the way that the variables are being parsed as well, I'll have to look at that closely |
|
|
|
|
|
#5 |
|
Confirmed User
Join Date: Jan 2002
Location: In the walls of your house.
Posts: 3,985
|
I must be missing something because I think what you're tring to do is incredibly easy.
Instead of: if ($value ne "nochoice") {$modifyfield = 26; $searchtext eq $value;} Use: if ($value eq 'yes' || $value eq 'no') {$modifyfield = 26; $searchtext eq $value;}
__________________
"Every normal man must be tempted, at times, to spit on his hands, hoist the black flag, and begin slitting throats." --H.L. Mencken |
|
|
|
|
|
#6 |
|
Confirmed User
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
|
Thanks netrodent, that'd work in this scenario, only because there are two variables, on other fields there are numerous form choices
I tried it, but it is not working whatsoever, which makes me think perhaps it's the way the form is being parsed or else the perl on my server is screwed up, however other scripts work fine... so I am going to do some cut and paste (*fval) = @_ if @_ ; local ($buf); if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$buf,$ENV{'CONTENT_LENGTH'}); } else { $buf=$ENV{'QUERY_STRING'}; } if ($buf eq "") { return 0 ; } else { @fval=split(/&/,$buf); foreach $i (0 .. $#fval){ ($name,$val)=split (/=/,$fval[$i],2); $val=~tr/+/ /; $val=~ s/%(..)/pack("c",hex($1))/ge; $name=~tr/+/ /; $name=~ s/%(..)/pack("c",hex($1))/ge; if (!defined($field{$name})) { $field{$name}=$val; } else { $field{$name} .= ",$val"; #if you want multi-selects to goto into an array change to: #$field{$name} .= "\0$val"; } } } return 1; what do you think??? |
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
|
whoa, I think in pasting, I just saw a problem...
"if you want multiple selects...." dumb da dumb dum, I am going to go have a coffee break and then try it ..... hopefully it will work... - but it's been two days and counting so far |
|
|
|
|
|
#8 | |
|
Confirmed User
Join Date: Aug 2001
Location: New Orleans
Posts: 1,680
|
Quote:
In other words, if you have 'SELECT NAME="selection" ', you need to use: if ($field{'selection'} ne "nochoice") {$modifyfield = 26; $searchtext eq $field{'selection'};} (edit to remove that second instance of $value, since it is never assigned. )
__________________
<CENTER><A HREF="http://www.hot-off-bourbon.com/" target="_blank"><IMG SRC="http://www.hot-off-bourbon.com/images/hob-logosmall.jpg" border="0"></A> <FONT face="Comic Sans MS" SIZE="-1"><I>Mardi Gras, Spring Break, Wet-T, Night Club Action, UpSkirt, Oil Wrestling, Voyeur</I></FONT></CENTER> |
|
|
|
|
|
|
#9 |
|
Confirmed User
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
|
Thanks
I do have a variable assignment $value = $field{'value'} ; earlier in the program, but I'll also try your suggestion I looked at the parse sub, and it does not seem exactly right to me either tho... maybe I am seeing things, but it does not look like som otheres I have seen |
|
|
|
|
|
#10 | |
|
Confirmed User
Join Date: Aug 2001
Location: New Orleans
Posts: 1,680
|
Quote:
$value = $field{'NAME_OF_SELECT_AS_GIVEN_IN_THE_FORM'} ;
__________________
<CENTER><A HREF="http://www.hot-off-bourbon.com/" target="_blank"><IMG SRC="http://www.hot-off-bourbon.com/images/hob-logosmall.jpg" border="0"></A> <FONT face="Comic Sans MS" SIZE="-1"><I>Mardi Gras, Spring Break, Wet-T, Night Club Action, UpSkirt, Oil Wrestling, Voyeur</I></FONT></CENTER> |
|
|
|
|
|
|
#11 |
|
Confirmed User
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
|
I appriciate the help very much believe me!
I have the variables similar to this, but the variables correspond to the form and the script variables $value1 = $field{'forminput1'} ; $value2 = $field{'forminput2'} ; $value3 = $field{'forminput4'} ; The script is printing the correct input variable as a flag in the document, so I know that it is correct, and recieved from the form input the problem I am having is the ability to process and compare the string equality within the subroutine beyond the if statement damn frustrating, it is, because as far as I can see, I am doing everything by the book |
|
|
|