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

I'm a little vexed as far as how to go about sending an argument to my perl script in the URL. I thought I could send it like this:

<!--#exec cgi="/cgi-bin/das_counter.pl?ilikepie"-->

and receive it like this:

$pielove=$ENV{QUERY_STRING};

However, I'm getting, "an error occurred while processing this directive". What am I missing?

Replies are listed 'Best First'.
Re: Passing data via URL in include
by asz (Pilgrim) on Jan 29, 2006 at 10:13 UTC
    you could provide us more information about what kind of error occured... you can find that in the logs of your web server.

    does your CGI program work as expected ? when run like http://localhost/cgi-bin/das_counter.pl?ilikepie do you get anything in $ENV{QUERY_STRING} ?

    assuming you're using Apache, you should try something like this:
    <!--#include virtual="/cgi-bin/das_counter.pl?ilikepie" -->
    "if you need to pass additional arguments to a CGI program, using the query string, this cannot be done with exec cgi, but can be done with include virtual" ( Apache mod_include )

    also, you'd better be using the CGI module so you don't have to mess around with (low-level) stuff like processing the QUERY_STRING.

    :)))))
Re: Passing data via URL in include
by wfsp (Abbot) on Jan 29, 2006 at 11:10 UTC
    This worked for me.
    <html> <head> <title>ssi demo</title> </head> <body> <h1>ssi demo</h1> <!--#include virtual="ssi_test.cgi?q=hi!"--> </body> </html>
    ssi_test.cgi
    #!/usr/bin/perl use strict; use warnings; use CGI::Simple; my $q = CGI::Simple->new; print $q->header; my $param = $q->param('q'); print qq|<h1>$param</h1>|;
    output
    ssi demo hi!
      Thank you!

      The exec was the problem after all. A virtual include works fine.