在HTML表单中,如果我们给输入框命名[],就像这样
<input name="foo[]" type="text" />
<input name="foo[]" type="text" />
Run Code Online (Sandbox Code Playgroud)
在PHP中,我们可以在数组中获取这些输入框的值$_POST['foo'].
如何在Perl中做类似的事情?我用CGI.pm
cjm*_*cjm 14
只需将结果分配给param数组即可.
my @values = param('foo[]'); # If you use the functional-style
my @values = $query->param('foo[]'); # If you use the OO-style of CGI.pm
Run Code Online (Sandbox Code Playgroud)
不要求名称以[].结尾.