Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

uri

cgi

perl

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

like image 842
joe Avatar asked Jun 15 '09 15:06

joe


People also ask

How do I find the parameter of a URL?

For getting the URL parameters, there are 2 ways: By using the URLSearchParams Object. By using Separating and accessing each parameter pair.

How are parameters passed in CGI?

use CGI; somewhere near the top of your program. The use statement is somewhat like a #include statement in C programming in that it pulls in code from another file at compile time. But it also allows optional arguments specifying which functions and variables you'd like to access from that module.

What is CGI parameters in URL?

The base URL indicates what account the customer is searching, and a set of CGI parameters (key-value pairs) that indicate how to return the desired search results for the associated account. The base URL is associated with a specific account and a staged or live environment.

Which method display the parameter and data path in URL?

URL getPath() method in Java with Examples The getPath() function is a part of URL class. The function getPath() returns the Path name of a specified URL.


2 Answers

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.

like image 119
ysth Avatar answered Sep 19 '22 15:09

ysth


It's recommended that you use a URL parser such as mentioned by ysth, but if you REALLY want the raw input, it's available through the following:

for GET:

$contents = $ENV{'QUERY_STRING'};

for POST:

$contents = <STDIN>;
like image 27
Powerlord Avatar answered Sep 22 '22 15:09

Powerlord