当前位置: 动力学知识库 > 问答 > 编程问答 >

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 @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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: