Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(dkubb) Re: (2) Oops! (Query String messed up)

by dkubb (Deacon)
on Mar 12, 2001 at 14:20 UTC ( #63790=note: print w/replies, xml ) Need Help??


in reply to Oops! (Query String messed up)

Well, you could use a regex to URL encode all the elements in your URL parameters, then join them together into a single query string.

But, there is a much simpler way, using the CPAN module URI.

Below is an example program using URI that does something similar to what you want:

#!/usr/bin/perl -w use strict; use URI; use constant BASE_URL => 'index.pl'; use constant REFERER => 'http://search.cpan.org/search?dist=URI'; my $uri = URI->new(BASE_URL); $uri->query_form( location => 'Redirect', URL => REFERER, referer => 'Links', ); print $uri;

A well formed URL will be printed out, and any parameters will be URL encoded properly.

A nice bonus is that the code made with URI is easy to read and hides all the potentially messy URL construction/encoding details from you. I almost never work with URL's by hand any longer since I started to use this module.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63790]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-08-16 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?