Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This is probably more of an http question than a Perl question even though my scripts are Perl. It just seems like someone here always has the answer anyway.... ;) When passing data into a script with the GET method, ie, adding arguments in the URL, there are certain characters that can't be used, such as +, & and %... I believe these should be written in the path translated to a string like '%22' or similar. It's just that I can't for the life of me find a list of what characters must be translated and what they are translated TO. Since this is mucking up my script pretty badly, I could really use a link here...

Replies are listed 'Best First'.
Re: CGI URL translation
by jeffa (Bishop) on Sep 07, 2003 at 14:59 UTC
Re: CGI URL translation
by Roger (Parson) on Sep 08, 2003 at 01:33 UTC
    You could use the URI module to construct your GET method by doing:

    use URI; $uri = URI->new("http://mysite/cgi/query.pl")->canonical; $uri->query_form(var1 => 'VAR1', var2 => 'VAR2'); $content = get($url);
    Where var1/var2 are the CGI variables. The beauty of this method is that the variables are automatically escaped.