Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Dynamicly Execute URL without redirection

by Anonymous Monk
on Feb 11, 2004 at 15:56 UTC ( [id://328293]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a URL that I would like to execute. I need variables in the URL to be posted correctly like this:

myperlscript.pl?var1=1&var2=2

I just dont want to redirect.

I so far have tried all of these things:

print qx "myperlscript.pl?var1=1&var2=2"; system("myperlscript.pl?var1=1&var2=2");use my $response =LWP::UserAgent->new->get("myperlscript.pl?var1=1&var2=2" +);

Thanks!!!

20040211 Edit by Corion: Exchanged PRE tags for formatting

Replies are listed 'Best First'.
Re: Dynamicly Execute URL without redirection
by tcf22 (Priest) on Feb 11, 2004 at 16:00 UTC
    You have to specify the whole URL so
    my $response =LWP::UserAgent->new->get("http://www.mydomain.com/myperl +script.pl?var1=1&var2=2");
    should be what you want.

    UPDATE:
    If you just want to run the script, then LWP::UserAgent may be overkill. LWP::Simple will probably do what you want.
    use LWP::Simple; my $data = get("http://www.mydomain.com/myperlscript.pl?var1=1&var2=2" +);

    - Tom

Re: Dynamicly Execute URL without redirection
by valdez (Monsignor) on Feb 11, 2004 at 19:29 UTC

    If you want a correct URL use the URI module to build it, for example:

    $uri = URI->new('http://www.example.com/myperlscript.pl'); $uri->query_form( 'var1' => $var1, 'var2' => $var2 ); $page = get( $uri->as_string );

    HTH, Valerio

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found