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

Hi monks, I have a script (source.cgi) in which there is this piece of code:
$testo=qq(<a href="/cgi-bin/a_test/test.cgi?id=$id">$testo</a>);
It sends the $id value to the Url and, as I hope, I should be able to retrieve the $id value in test.cgi. But unfortunately I can not. In test.cgi if I type: print "this is param: " param();, the output is: this is param: id
Thus it is evident it just prints the string between ? and =.

Replies are listed 'Best First'.
Re: passing param value throughout GET method
by samtregar (Abbot) on May 20, 2008 at 20:29 UTC
    Furthermore, it is evident that you did not read the docs: CGI. The param() routine returns a list of available params in list context - hence ('id') in your case. If you want the value call param('id').

    -sam

Re: passing param value throughout GET method
by leighsharpe (Monk) on May 21, 2008 at 05:25 UTC
    You're not using param() correctly.
    You have passed 'id=$id' to your CGI. Therefore, you can expect param('id') to return the value contained in $id.
    If you had this in source.cgi:
    $testo=qq(<a href="/cgi-bin/a_test/test.cgi?id=$id&fred=wombat">$testo +</a>);
    Then you could do something like this:
    foreach(param()) { print "$_ = ".param($_)."<br>\n"; }
    And you would get:
    id = [whatever was in $id] fred = wombat

    This should demonstrate the two ways to call param().