开发者

perl CGI, differences with param vs Var

I do this in my cgi perl script:

my %USER_HTML_INPUT = Vars();

I noticed that if have an array of data assigned to one key it becomes like this:

$VAR= {'tempvalue' => '0�25�85�125' }; 

If i do @开发者_Go百科DATA = param('tempvalue'); It splits the values into the array.

How can I do the same operation without using param function.?


If you really, really want to do this without param, you could try something like (untested):

my $vars = Vars();
my %USER_HTML_INPUT = map { $_ => [ split(m{\0}, $vars->{$_}) ] } keys %$vars;

but slightly less ugly:

my %USER_HTML_INPUT = map { $_ => [ param($_) ] } param();

It is much cleaner, though, to simply use param on the parameters that you need.

Also read the section DEBUGGING of the CGI documentation to see how you can pass CGI parameters to a script using CGI.pm from the command-line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜