#!/usr/bin/perl
#############################################################################
## Configuration area
##
## Full or relative path to log-file
$pod_logging = "../pod_searches.log";
##
## Number of lines to print
$no_lines = 5;
##
## Number of characters (in each line) to print
$no_char = 25;
#############################################################################
use CGI qw(:all);
print header;
print "<B>Latest Searches:</B><BR>\n";
#
# Total lines
if (-e "$pod_logging")
{
open (CL, "$pod_logging");
while (<CL>

{
$totallines++
}
close (CL);
}
# Read file
$startdata = $totallines - $no_lines;
if (-e "$pod_logging")
{
open (TL, "$pod_logging");
for ($count = 0; $count < $totallines; $count += 1)
{
$line = <TL>;
if ($count >= $startdata)
{
chomp $line;
$lastline[$count - $startdata] = $line;
}
}
close (TL);
}
# Cleanup data and print it.
for ($clean = 0; $clean < $no_lines; $clean += 1)
{
$lastline[$clean] = substr($lastline[$clean], 12, $no_char+1);
@lastlinetemp = split(/\&/, $lastline[$clean]);
$lastline[$clean] = $lastlinetemp[0];
if (length($lastline[$clean]) > $no_char)
{
$lastline[$clean] = $lastline[$clean]."...";
}
print $lastline[$clean]."<BR>\n";
}
Comment: There might be some errors that I have not spotted in this since I had to change every
+,>,< to make them visible in this post...
To see this script in action, go to
http://www.berka.com/