如何使用 HTML 表单将数组传递给 perl cgi 脚本?

发布于 2024-09-14 12:49:19 字数 258 浏览 3 评论 0原文

在 HTML 表单中,如果我们使用 [] 为输入框命名,就像这样

<input name="foo[]" type="text" />
<input name="foo[]" type="text" />

在 PHP 中,我们可以通过 $_POST['foo' 获取数组中这些输入框的值]

如何在 Perl 中做类似的事情?我用CGI.pm

In a HTML form, if we give names to input boxes with [], like this

<input name="foo[]" type="text" />
<input name="foo[]" type="text" />

In PHP, we can obtain values of these input boxes in an array, with $_POST['foo'].

How to do the similar in Perl? I use CGI.pm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然 2024-09-21 12:49:19

只需将 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

名称不要求以 [] 结尾。

Just assign the result of param to an array.

my @values = param('foo[]');         # If you use the functional-style
my @values = $query->param('foo[]'); # If you use the OO-style of CGI.pm

There's no requirement that the name end with [].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文