Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re: Best way to generate URLs in CGI script?

by bikeNomad (Priest)
on Jul 27, 2001 at 06:18 UTC ( #100212=note: print w/replies, xml ) Need Help??

in reply to Re: Best way to generate URLs in CGI script?
in thread Best way to generate URLs in CGI script?

I tried this first, but what happened is that the query string got interpreted as a keyword. Let's say that I wanted the (relative) URL to be graph?a=b&c=d :

my $target = CGI->new( 'graph' ); $target->param( -a => 'b', -c => 'd' ); $target->url; # 'http://localhost/cgi/originalPath' $target->query_string; # 'keywords=graph' $target->param; # 'keywords'

So this didn't work...

Replies are listed 'Best First'.
Re: Re: Re: Best way to generate URLs in CGI script?
by synapse0 (Pilgrim) on Jul 27, 2001 at 06:33 UTC
    Ok.. well I can honestly say I'm not sure what you're trying to do then.. are you trying to call an external program and give it the query string?? if so, you can just set $ENV{QUERY_STRING} to your string, and exec the other cgi.. Otherwise, I need a little clarification..
    (i'm at work right now and only half paying attention, that may have something to do with it...)
      I've got an image that's generated by another CGI script. So I want to generate something that looks like:

      <img src="graph&channel=1&xsize=300&ysize=400">
        No you don't. You want to generate
        <img src="graph?channel=1&amp;xsize=300&amp;ysize=400">
        This is HTML, so HTML entities must be escaped. The code is somewhat simple (typing this from memory, so be kind if I've made a mistake):
        use URI; use HTML::Entities; my $uri = URI->new("graph", "http"); $uri->query_form(channel => 1, xsize => 300, ysize => 400); print "<img src=\"", encode_entities($uri->as_string), "\">";

        -- Randal L. Schwartz, Perl hacker

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2021-05-14 06:22 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (148 votes). Check out past polls.