I need help on the following perl module which displays last modified time in all html pages of "/home/perlguy/test" dir. I am using Apache Webserver.
Prg. search for <BODY> tag if found prints Last modified time
package Apache::Mytest;
# file Apache::Mytest.pm
use strict vars;
use Apache::Constants ':common';
use IO::File;
sub handler {
my $r = shift;
return DECLINED unless $r->content_type() eq 'text/html';
my $file = $r->filename;
return DECLINED unless $fh=IO::File->new($file);
my $modtime = localtime((stat($file))[9]);
my $mytime=<<ENDTIME;
<hr>
<em>This Page Last Modified: $modtime</em>
<hr>
ENDTIME
;
$r->send_http_header;
while (<$fh>) {
s!(<BODY>)!$footer$1!oi;
} continue {
$r->print($_);
}
return OK;
}
1;
__END__
The above module is stored as "Mytest.pm" in the
"/home/perlguy/test" dir.
then I added following lines in "srm.conf" file :
<Location /home/perlguy/test>
SetHandler perl-script
PerlHandler Apache::Mytest
</Location>
Then I restarted Apache server but got following error...
Starting httpd: Syntax error on line 89 of /etc/httpd/conf/srm.conf:
Invalid command 'PerlHandler', perhaps mis-spelled or defined by a module not included in the server configuration.
Any idea why Apache server is giving this error?
Do I need to compile module? If yes how?
Any help would be appreciated.
perlguy.
Prg. search for <BODY> tag if found prints Last modified time
package Apache::Mytest;
# file Apache::Mytest.pm
use strict vars;
use Apache::Constants ':common';
use IO::File;
sub handler {
my $r = shift;
return DECLINED unless $r->content_type() eq 'text/html';
my $file = $r->filename;
return DECLINED unless $fh=IO::File->new($file);
my $modtime = localtime((stat($file))[9]);
my $mytime=<<ENDTIME;
<hr>
<em>This Page Last Modified: $modtime</em>
<hr>
ENDTIME
;
$r->send_http_header;
while (<$fh>) {
s!(<BODY>)!$footer$1!oi;
} continue {
$r->print($_);
}
return OK;
}
1;
__END__
The above module is stored as "Mytest.pm" in the
"/home/perlguy/test" dir.
then I added following lines in "srm.conf" file :
<Location /home/perlguy/test>
SetHandler perl-script
PerlHandler Apache::Mytest
</Location>
Then I restarted Apache server but got following error...
Starting httpd: Syntax error on line 89 of /etc/httpd/conf/srm.conf:
Invalid command 'PerlHandler', perhaps mis-spelled or defined by a module not included in the server configuration.
Any idea why Apache server is giving this error?
Do I need to compile module? If yes how?
Any help would be appreciated.
perlguy.