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

Hi All, How to pass more than one parameter with url
<a href=/cgi-bin/test.pl?hello=2&hai=3>TEST</a>
how to parse in the test.pl.
my $test1 = in{'hello'};
my $test2 = in{'hai'};
Thanks
blazix

Replies are listed 'Best First'.
Re: passing more than one parameter
by Ovid (Cardinal) on Aug 12, 2004 at 15:40 UTC
      it is not working since while logging in only it is checking and blocking the after login page


      blazix

        I'm afraid I don't understand. We need a lot more information to know what you are doing. Specifically, we need to know four things:

        1. What are you trying to do?
        2. How you are trying to do it?
        3. What results do you expect?
        4. What results are you getting?

        In short, we need to know enough about what you're doing and how it's failing so we can reproduce your problem. You understand your problem well enough that perhaps you're simply assuming too much knowledge on our part. Assume that we know nothing (except Perl), start from the beginning, and explain what's going on.

        Cheers,
        Ovid

        New address of my CGI Course.

Re: passing more than one parameter
by TrekNoid (Pilgrim) on Aug 12, 2004 at 19:21 UTC
    This is actually the first ever program I wrote in Perl, so I *know* there's got to be a better way to do it, since it seems that there's always a better way than the first way I did everything :)... but adapting it from your code snippets, if your call is:
    <a href=/cgi-bin/test.pl?hello=2&hai=3>TEST</a>
    and you want test.pl to put the 'hello' in $test1 and 'hai' in $test2, then the following code in test.pl *should* get close to what you're after:
    $params = $ARGV[0]; ($test1, $test2) = split('&', $ARGV[0]);
    Although, technically, that will assign 'hello=2' to $test1 and 'hai=3' to $test2... but you should be able to split those off pretty easily

    I haven't tested it with an ampersand, but I know that it worked in my early app, which used the colon ':' as a separator...

    Trek