Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

mod_perl provides a way to run perl scripts in httpd.conf:

...scripts goes here...

How do I configure httpd.conf so that scripts inside <perl></perl> only get run if there's a flag parameter in the querystring?

share|improve this question

Use Perl to evaluate the query_string and then use an if statement to skip the rest if the parameter is not set.

Perhaps something like this*:

     if (length ($ENV{'QUERY_STRING'}) > 0){
           $buffer = $ENV{'QUERY_STRING'};
           @pairs = split(/&/, $buffer);
           foreach $pair (@pairs){
                ($name, $value) = split(/=/, $pair);
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
                $in{$name} = $value; 
     if (defined $in{'flag'}){
          #Your Code here

*there might be other ways to break up the query_string, here's where I got my example.

share|improve this answer
It seems it's not per request,it's only loaded once when Apache starts up... – linux Jul 20 '11 at 6:52
it works only in CGI mode,which is not the case for mod_perl. – kernel Jul 21 '11 at 11:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.