<!-- #perl --> support for Apache 2.0

geoff on 2003-09-16T13:58:15

yesterday, I released Apache::IncludeHook to CPAN. it provides support for #perl SSI tags in the following formats:



<!--#perl sub="My::PrintArgs" -->
<!--#perl arg="fee" sub="My::PrintArgs" arg="fie" -->


<!--#perl arg="foe" sub="My::PrintArgs::handler" -->
<!--#perl arg="fum" sub="My::PrintArgs->method_handler" -->
<!--#perl arg="I smell" sub="sub { my $r = shift; print @_ }" -->




the coolish thing is the interface. as you may already know, mod_include is an output filter in Apache 2.0. for custom tags, this means that the tag implementation also needs to be a filter. however, rather than require that #perl code understand the filtering API, I made it possible to write to an output filter using $r->print() or just print(). it was pretty cool to see this idiom



sub new {



 my ($class, $r) = @_;



 return tie *STDOUT, $class, $r;
}



sub TIEHANDLE {



 my ($class, $r) = @_;



 return bless { r => $r }, $class;
}




working in mod_perl 2.0 as well.