T-Lo has asked for the wisdom of the Perl Monks concerning the following question:

I have a really basic question... anyone have a snippit of code that will get values from a url?
example:

myscript.cgi?value1=wee&value2=bah

then in the script I would get $value1=wee and $value2=bah

again, Im just learning it so I know this is a really stupid question. :*(

Replies are listed 'Best First'.
Re: get a value from a URL
by artist (Parson) on Jun 19, 2003 at 00:16 UTC
    Assuming that you are writing a cgi-script,
    use CGI; my $query = new CGI; %params = $query->Vars; foreach (keys %params){ print "$_\t",$params{$_},"\n"; }
    <code untested but should work.
    Also read: Tutorials for CGI from our ovid at his CGI Course

    artist

Re: get a value from a URL
by antirice (Priest) on Jun 18, 2003 at 23:54 UTC

    Take a look at CGI. Specifically the param method from CGI.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: get a value from a URL
by Abstraction (Friar) on Jun 19, 2003 at 03:58 UTC
    Another option you have is to use CGI::Simple. It's a drop in replacement for CGI that doesn't have all the HTML generation methods.
Re: get a value from a URL
by Anonymous Monk on Jun 19, 2003 at 09:37 UTC
    Use this code.. use CGI; $query=new CGI; $value1 = $query->param('value1'); $value2 = $query->param('value2'); No problem ... now u have a final answer. Sureshp