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

Fellow Monks,
I would like to simulate a GET through a normal HTML link generated from a CGI script. The link is to another CGI script. I do not want to use a form. So I have a link that I prepare as follows:

<a href="../cgi-bin/script.cgi?field1=value1&field2=value2">Click Here</a>

How would I go about retreiving the field1 and field2 values in the script.cgi code? I have been useing the POST method when dealing with forms. Is it possible to perform a POST with a normal HTML link like this? Or am I going about this the right way? Maybe a cookie?

Thank You :-)

Replies are listed 'Best First'.
Re: Passing Variables to CGI script?
by Roger (Parson) on Dec 09, 2003 at 23:29 UTC
    To retrieve the field1 and field2 values in your script.cgi -
    use CGI; my $q = new CGI; my $q_field1 = $q->param('field1'); my $q_field2 = $q->param('field2');
      Thanks Roger! That did the trick! This was exactly the same thing I was doing via forms useing POST ;-)