[thelist] perl: show me the last n lines from this file
Hassan Schroeder
hassan at webtuitive.com
Fri May 11 15:31:29 CDT 2001
Sam-I-Am wrote:
>
> I'm trying to build a page (cgi) that displays the last say 20 access
> from the web access-log. (or 5k, or whatever)
Starting with your code snippet, I tried this:
--------------------------------------------------------------------
#!perl
open (SYSLOG, "tac access.log|") or die "Can't open syslog: $!,";
$count = 0;
while (<SYSLOG>) {
if ( $count < 21 )
{
print;
$count++;
}
else
{
exit;
}
}
--------------------------------------------------------------------
.. and it works fine on my Win2000+cygwin system.
HTH!
--
H*
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ---(+1) 408-938-0567 --- http://www.webtuitive.com
-- creating dynamic Web sites and applications since 1994 --
More information about the thelist
mailing list