如何在Perl CGI程序中读取URL参数? [英] How can I read the URL parameter in a Perl CGI program?

查看:118
本文介绍了如何在Perl CGI程序中读取URL参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Perl CGI程序中读取URL参数?

解决方案

对于 GET请求 >, CGI 解析指定的参数,并通过 param使它们可用()方法。



对于 POST请求 param()将从后数据中返回参数,但是通过URL本身中的查询字符串指定的任何参数仍可通过 url_param()方法使用。 (当POST请求大于 $ CGI :: POST_MAX 时,这将很有帮助;在这种情况下,CGI只会丢弃postdata,但是您可以安排使用查询字符串参数来标识提供良好错误消息的请求类型。)



对于 ISINDEX样式请求,可以通过以下方式获得所请求的关键字: keywords()方法,以及通过 param()使用伪造的关键字参数。



更新:如果您的意思不是 URL参数中的参数,则 url()方法提供全部或部分请求的URL;参见获得脚本的URL 。 / p>

How can I read the URL parameter in a Perl CGI program?

解决方案

For GET requests, CGI parses the specified parameters and makes them available via the param() method.

For POST requests, param() will return the parameters from the postdata, but any parameters specified via a query string in the URL itself are still available from the url_param() method. (This is can be helpful when a POST request is larger than $CGI::POST_MAX; in that case, CGI just discards the postdata, but you can arrange to have query string parameters that identify what kind of request it was to provide a good error message.)

For ISINDEX style requests, the keywords requested are available via the keywords() method, as well as via param() in a faux "keywords" parameter.

Update: in case you meant something other than the parameters by "URL Parameter", the url() method provides all or parts of the requested URL; see OBTAINING THE SCRIPT'S URL.

这篇关于如何在Perl CGI程序中读取URL参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆