On 3/9/02 10:25 PM, Troy May <[EMAIL PROTECTED]> wrote:
> The second one:
>
> How to use the query string to determine what part of a CGI script runs?
>
> I need to have the form button execute a certain part of the script.
Thanks for the specification.
The query string is stored in the variable $ENV{'QUERY_STRING'}. So, you
could easily do something like this:
if ($ENV{'QUERY_STRING'} eq 'do_stuff'){
my_subroutine();
}
elsif($ENV{'QUERY_STRING'} eq 'do_other_stuff'){
my_other_subroutine();
}
else{
do_other_stuff();
}
Or, you could get fancy and do something like this:
&{$ENV{'QUERY_STRING'}}();
That runs the subroutine of the name of the query string. For instance, if
you called the script like 'script.cgi?do_things', it would look for
do_things(). I would NOT recommend this, though, because if someone found
your script, they could run subroutines you did not intend to be run like
this. As slick as it looks, I highly recommend the first one.
Hope that helps!
--
Michael
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]