note
Logicus
<code>
Listing test2.cgi
-----------------
#!/usr/bin/perl
use Modern::Perl;
use aXML2;
my $stash = { title => "bob's bit's emporium" };
sub a { " foo " }
<aXML>
<html>
<head>
<title>[my]stash->{'title'}[/]</title>
</head>
<body>
<perl>print "hi";</perl> (a)b(/)
</body>
</html>
</aXML>
listing aXML2.pm
----------------
package aXML2;
use Filter::Util::Call;
my $header = 'print "Content-type: text/html\n\n";';
sub import {
my ($type) = @_;
my ($ref) = [];
filter_add(bless $ref);
}
sub filter {
my ($self) = @_;
my ($status);
do {
if (s@<aXML>@$header print qq\@@s) { $header = " "; }
s@</aXML>@\@;@s;
s@<perl>@\@;@s;
s@</perl>@print qq\@@s;
s@\(([^\(]*?)\)([^\(]*?)\(/\)@\@; print &$1('$2'); print qq\@@s;
s@\[my\](.*?)\[/\]@\$$1@gs;
} if $status = filter_read() > 0;
$status;
}
1;
</code>
<p>test2.cgi works under plain CGI but not under mod_perl using : </p>
<code>
Listing httpd.conf
------------------
AddHandler cgi-script .cgi
PerlModule Apache::DBI
<Files *.pl>
SetHandler perl-script
PerlHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order allow,deny
Allow from all
</Files>
</code>
922916
922917