[thelist] perl: show me the last n lines from this file

Michael Styer mas at codix.net
Mon May 14 04:14:43 CDT 2001


On Sat, 12 May 2001, Anthony Baratta wrote:

> At 01:29 PM 5/11/2001, you wrote:
> >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)
> 
> If this is a *NIX box why not try using the "tail" command?
> 
> e.g.
> 
>     $Last20Lines = `tail -20 $TargetFileName`;
> 
>     print $Last20Lines;

if you want to look at them in reverse order (LIFO):

@last_lines = reverse `tail -20 $file_name`;

> ---
> Anthony Baratta
> President
> Keyboard Jockeys
> 
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt ! 
> 
--
Michael Styer		mas at codix.net
phone: 020 7603 5723	107 Shepherd's Bush Rd
fax: 020 7603 2504	London W6 7LP





More information about the thelist mailing list