CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
perl bug comparing param

 



netocaponeto
New User

Mar 4, 2008, 4:09 PM

Post #1 of 8 (2117 views)
perl bug comparing param Can't Post

I have a form where the number of variables range from 0 to 200 I use the statement if(param('myvar1') ne ""){

do something

}

I use it to check if the variable exists. when I reach the variable number 101 approx. then the script freezes. Any ideas?


netocaponeto
New User

Mar 5, 2008, 10:10 AM

Post #2 of 8 (2107 views)
Re: [netocaponeto] perl bug comparing param [In reply to] Can't Post

I just found the answer myself. Simply save the contents of param in another variable and give it a default value if param is false e.g.

Code
for ($i=0;$i<100000;$i++){  
my $temp=param('myVar'.$i) || "";
if($temp ne ""){
#print anything
}
}



KevinR
Veteran


Mar 5, 2008, 11:31 AM

Post #3 of 8 (2106 views)
Re: [netocaponeto] perl bug comparing param [In reply to] Can't Post

why are you looping 100,000 times?
-------------------------------------------------


netocaponeto
New User

Mar 5, 2008, 1:24 PM

Post #4 of 8 (2104 views)
Re: [KevinR] perl bug comparing param [In reply to] Can't Post

I looped 100,000 times for two reasons: to test if there is a limitation in perl (checking for x number of variables that do not exists), second, I have a complex form that has lots of values with different names then I send the form to perl to generate a report and perl script has to check if the variable exists before printing it in the format I want.


KevinR
Veteran


Mar 5, 2008, 1:36 PM

Post #5 of 8 (2103 views)
Re: [netocaponeto] perl bug comparing param [In reply to] Can't Post


In Reply To
I looped 100,000 times for two reasons: to test if there is a limitation in perl (checking for x number of variables that do not exists), second, I have a complex form that has lots of values with different names then I send the form to perl to generate a report and perl script has to check if the variable exists before printing it in the format I want.


Perl has no limits in that regards but the operating system might. CGI Forms with lots of fields can consume a lot of memory on the client's computer, if you put too many on one page you can start to crash peoples computers. Just something to be aware of in case you are not already.
-------------------------------------------------


netocaponeto
New User

Mar 5, 2008, 1:44 PM

Post #6 of 8 (2101 views)
Re: [KevinR] perl bug comparing param [In reply to] Can't Post

You're somewhat right. But if you read the first post I found that you cannot compare (about 150 times) non exsisting or existing param variables using perl e.g. if(param('var150') eq ""){ } The script hangs and it does not have anything to do with memory. Reply number 2 gave me the solution to this case. Thanks for your attention.


KevinR
Veteran


Mar 5, 2008, 3:55 PM

Post #7 of 8 (2099 views)
Re: [netocaponeto] perl bug comparing param [In reply to] Can't Post


In Reply To
You're somewhat right. But if you read the first post I found that you cannot compare (about 150 times) non exsisting or existing param variables using perl e.g. if(param('var150') eq ""){ } The script hangs and it does not have anything to do with memory. Reply number 2 gave me the solution to this case. Thanks for your attention.


The problem would not be that perl can't compare x number of form paramaters, there is no such limitation in that regards. The hanging problem is being caused by something else. If you have access to the server error logs that is the place to start.
-------------------------------------------------


BorisE
Novice

May 18, 2008, 11:07 AM

Post #8 of 8 (1943 views)
Re: [netocaponeto] perl bug comparing param [In reply to] Can't Post

I think param returns undef instead of "" if the field didn't exist at all. A string compare on undef probably made it warn or die.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives