On Fri, May 26, 2006 at 10:35:41AM +1000, Keenan, Greg John (Greg)** CTR ** 
wrote:

> >Using a hash:
> >
> >for my $cfg ( keys %cfgs ) {
> >    my $fileIn = "$cfgDir/$cfg/tapelist";
> >    open FILEIN, '<', $fileIn or die "Could not open $fileIn: $!";
> >    print +( reverse <FILEIN> )[ -$cfg{$cfg} .. -1 ]; }
> >
> >
> >Also, if the files are large you can get better efficiency using
> >the File::ReadBackwards module.
> 
> Thanks for the solutions John, works a treat.  Files are quite small but
> will look into File::ReadBackwards

This seems to be doing a bit more work than might be required.  How
about this?

  print reverse map scalar <FILEIN>, 1 .. $cfg{$cfg};

Then you won't need to worry about how big the files are.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to