Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

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


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

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">

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Best way to generate URLs in CGI script?
by merlyn (Sage) on Jul 27, 2001 at 22:06 UTC
    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

      Actually, I only had to do this (still using CGI):

      use CGI; use URI; my $target = URI->new( 'graph', 'http' ); $target->query_form( channel => 1, xsize => $xsize, ysize => $ysize, ); print $q->img( { -width => $xsize, -height => $ysize, -src => $target->path_query } );

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2021-05-16 00:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (151 votes). Check out past polls.

    Notices?