Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Forcing %20 using URI?

by PopeFelix (Beadle)
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{}); $uri->path(q{/baz/bak}); my %form = ( 'quux' => 'alpha jub jub', ); $uri->query_form(%form); print qq{$uri\n};

Gives me, when I want

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

Replies are listed 'Best First'.
Re: Forcing %20 using URI?
by NetWallah (Canon) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1053984]
Approved by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2018-06-22 18:50 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.