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.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 01-23-2003, 12:52 PM   #1
Rip
Confirmed User
 
Join Date: Jan 2001
Location: somewheres wet
Posts: 1,456
perl gurus, string checking

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)

Last edited by Rip; 01-23-2003 at 12:54 PM..
Rip is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 01:47 PM   #2
FuqALot
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/)'.

Last edited by FuqALot; 01-23-2003 at 01:49 PM..
FuqALot is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 01:53 PM   #3
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
hit me up ...
__________________
MacDaddy Coder.
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 02:48 PM   #4
Rip
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
Rip is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 02:50 PM   #5
NetRodent
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
NetRodent is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 03:09 PM   #6
Rip
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???
Rip is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 03:12 PM   #7
Rip
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
Rip is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 03:20 PM   #8
fiveyes
Confirmed User
 
Join Date: Aug 2001
Location: New Orleans
Posts: 1,680
Quote:
Originally posted by Rip
...I have a simple form with user choices

1; value = 'nochoice'
1; value = 'yes'
1; value = 'no'
...
Remember, option choices are not assigned to 'value', but to the NAME of the selection. Also, all your values are being stored in a hashed array- %field.

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>

Last edited by fiveyes; 01-23-2003 at 03:28 PM..
fiveyes is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 03:27 PM   #9
Rip
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
Rip is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 03:30 PM   #10
fiveyes
Confirmed User
 
Join Date: Aug 2001
Location: New Orleans
Posts: 1,680
Quote:
Originally posted by Rip
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
OK, make that statement:
$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>
fiveyes is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2003, 03:41 PM   #11
Rip
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
Rip is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.