Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PERL CGI Get all GET parameters and put them together

Posted on 2008-09-29
16
Medium Priority
?
2,042 Views
Last Modified: 2013-12-25
I want to get ALL parameters of GET method and put them together in a single string variable...

ex.

If Test.pl?a=1&b=2&c=3&d=%20Test%20 called

I want to have a=1&b=2&c=3&d=%20Test%20 in a single string variable in same format with & and html encoded.

Thanks from now!
0
Comment
Question by:CSecurity
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 2
  • +1
16 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 22597400
You could just get the $ENV{QUERYSTRING}, and this would be exactly the querystring to your script.
0
 
LVL 17

Author Comment

by:CSecurity
ID: 22597476
I want URL and parameters all together

I mean:

http://www.mysite.com/test.pl?a=1&b=2&c=3&d=%20Test%20

I want entire URL
0
 
LVL 82

Expert Comment

by:hielo
ID: 22597508
$ENV{REQUEST_URI}
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 39

Expert Comment

by:Adam314
ID: 22597518
my $EntireURL = "http://www.mysite.com/test.pl?$ENV{QUERY_STRING}"
0
 
LVL 17

Author Comment

by:CSecurity
ID: 22597527
There isn't a method to get it dynamically?
0
 
LVL 39

Expert Comment

by:Adam314
ID: 22597533
The REQUEST_URI will not contain the protocol (http), or the domain (www.mysite.com).  And if the current page is different from the desired link, it will not be correct.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22597558

my $EntireURL = "$ENV{REQUEST_URI}?$ENV{QUERY_STRING}" ;
0
 
LVL 39

Expert Comment

by:Adam314
ID: 22597559
What do you want to get?  There are several environment variables that contain different parts of what you are asking for.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22597566
I meant SCRIPT_URI
my $EntireURL = "$ENV{SCRIPT_URI}?$ENV{QUERY_STRING}" ;
0
 
LVL 39

Expert Comment

by:Adam314
ID: 22597573
SCRIPT_URI?   I don't have this - I am using apache... what webserver are you using?
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 1200 total points
ID: 22597610
Here are some environment variables that might help with what you want:
SCRIPT_NAME   - The name of the script as seen by the web browser (eg: /test.pl)
SERVER_NAME   - The hostname (eg: www.mysite.com)
QUERY_STRING  - The part after the question mark (eg: a=1&b=2&c=3&d=%20Test%20)
SERVER_PORT   - The port, part after the colon of hostname, or 80 if not specified
REQUEST_URI   - "$ENV{SCRIPT_NAME}?$ENV{QUERY_STRING}"
HTTP_HOST     - "$ENV{SERVER_NAME}:$ENV{SERVER_PORT}"

Open in new window

0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 400 total points
ID: 22597750
>>SCRIPT_URI?   I don't have this - I am using apache... what webserver are you using?
apache. Not sure what version the webhost is using. It gives me the full url MINUS the querystring!
0
 
LVL 39

Expert Comment

by:Adam314
ID: 22597941
I'm using apache 2.2.8, which looks to be the newest release.... wondering if SCRIPT_URI is a non-standard add-on your host is using.
0
 
LVL 28

Assisted Solution

by:FishMonger
FishMonger earned 400 total points
ID: 22597945
Partial quote from http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
(SCRIPT_URI is probably documented elsewhere, but that was the first google hit)
This module keeps track of two additional (non-standard) CGI/SSI environment variables named SCRIPT_URL  and SCRIPT_URI. These contain the logical Web-view to the current resource, while the standard CGI/SSI variables SCRIPT_NAME and SCRIPT_FILENAME contain the physical  System-view.
 
Notice: These variables hold the URI/URL as they were initially requested, that is, before any rewriting. This is important to note because the rewriting process is primarily used to rewrite logical URLs to physical pathnames.
Example
 
SCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html
SCRIPT_FILENAME=/u/rse/.www/index.html
SCRIPT_URL=/u/rse/
SCRIPT_URI=http://en1.engelschall.com/u/rse/

Open in new window

0
 
LVL 39

Expert Comment

by:Adam314
ID: 22597953
With 2.2.8.... I meant 2.2 is the latest - there is a 2.2.9 released on 2008-06-13, but I doubt this would have changed.
0
 
LVL 39

Expert Comment

by:Adam314
ID: 22597974
Thanks FishMonger!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question