Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Forcing %20 using URI?

by PopeFelix (Sexton)
on Sep 13, 2013 at 18:08 UTC ( #1053984=perlquestion: print w/ replies, xml ) Need Help??
PopeFelix has asked for the wisdom of the Perl Monks concerning the following question:

So I want to create a URL using URI, because I like doing that better than I like creating the URL by hand.

#!/usr/bin/perl use strict; use warnings; use English qw/-no_match_vars/; use URI; use URI::QueryParam; my $uri = URI->new(q{http://foo.bar/}); $uri->path(q{/baz/bak}); my %form = ( 'quux' => 'alpha jub jub', ); $uri->query_form(%form); print qq{$uri\n};

Gives me http://foo.bar/baz/bak?quux=alpha+jub+jub, when I want http://foo.bar/baz/bak?quux=alpha%20jub%20jub.

Is there a way to get URI to encode spaces in the query string using %20?

Comment on Forcing %20 using URI?
Select or Download Code
Re: Forcing %20 using URI?
by NetWallah (Abbot) on Sep 13, 2013 at 18:47 UTC
    See URI::Encode, whose purpose in life is just this.

                 My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

      Nah, stick with URI::Escape, it comes with URI, but FWIW, + is the same as %20 and has been for over a decade :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1053984]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-10-02 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls