UBB.Dev
Posted By: Em8 auto varible per param - 02/22/2001 11:02 PM
I'm trying to figure out how to make a hash hold all params in the script. I mean like I have a param(name) and I want to make that automaticly $var{'name'}. How would I do this? I thought it would be like
Code
code:
but I get errors: 1 syntax error line 11, near "foreach "
2 Execution aborted due to compilation error


[ February 22, 2001: Message edited by: Em8 ]

[ February 23, 2001: Message edited by: Em8 ]
Posted By: Charles Capps Re: auto varible per param - 02/24/2001 8:50 AM
*edit* See below.

[ February 24, 2001: Message edited by: Charles Capps ]
Posted By: Charles Capps Re: auto varible per param - 02/24/2001 8:54 AM
The code's getting there, but isn't quite...

use CGI qw(:standard);
my($item,@params);
local(%form);
@params = param():
foreach $item (@params){
$form{$item} = param($item);
}

This should work, but has not been tested, yadda yadda...

Passing :standard to CGI allows you to use the (much easier) non-OO interface to CGI, so you can just call param() and header() and all the other nice functions. smile

[ February 24, 2001: Message edited by: Charles Capps ]
© UBB.Developers