http://qs321.pair.com?node_id=9737


in reply to When constructing a URL from script variables, how do I handle spaces properly?

In fact, if you are trying to construct
<a href="/cgi-bin/editmarine.pl?marine=$marineid">edit marine</a>
You'll run into a lot of problems if $marine is not URI-encoded. So the first step is to trot over to URI::Escape and run it through there. No spaces will be left!

Editor's note:

#Sample Code my $SafeMarine = URI::Escape::uri_escape($marineid); <a href="/cgi-bin/editmarine.pl?marine=$SafeMarine">edit marine</a>

Replies are listed 'Best First'.
RE: Answer: When constructing a URL from script variables, how do I handle spaces properly?
by steveAZ98 (Monk) on Jul 25, 2000 at 06:08 UTC
    I've also used the code below to replace spaces with the correct chars.
    $value =~ s/\s/\%20/g;
    And it seems to work good for my purposes.