> Is there a perl function equivalent to the *nix command
> 'tail'?

Here is a basic Perl implementation of tail:

#!/usr/bin/perl
@a=<>;print@a[-10,-1];

IIRC there is a shorter way to do it, but that'd
mean going back over the FWP mailing list archives.
 
> I don't mean like, a workaround through loops
> that will produce the same sort of result, just
> a function.

sub tail (\@) {
    my $array = shift;
    return @$array[-10,-1];
}

> Also, what are the benefits of using the function
> grep?

Lots, cross platform, NFA engine (not DFA) hence
backtracking and lookahead/lookbehinds etc.

> Doing a system call to grep seems to run faster
> than the perl function!

It probably will, since the system grep is built for
absolute speed in the small task it does.  Perl is a
little more general, and the grep patterns are just
as powerful as any other regex in Perl.

Platform independence springs to mind too... and also
if you already have data in memory (in Perl) writing
it out to disk is a pain that none of us bother with.

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to