Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me on this Perl Module 1

Status
Not open for further replies.

perlguy

Programmer
May 17, 2001
26
US
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 &quot;Mytest.pm&quot; in the
&quot;/home/perlguy/test&quot; dir.

then I added following lines in &quot;srm.conf&quot; 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.
 
Have you tried the third element in the head function to get last modified header?

Something similiar to this:
[tt]

use LWP::Simple

my ($timer) = (head('[2];
my ($timerout) = scalar localtime($timer);[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top