Sukrit wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Listers,
> How do i delete the last 12 (or so) lines of a large file (400+ lines)
> without loading the whole into memory.

400 lines isn't too huge. I would say just read the file once to count
the
lines. Then re-read it, printing twenty less lines than you counted.
It's
dirty but it's quick :)

I'll even have a stab at the code for you:

    use strict;
    use warnings;

    open FILE, 'ppm_search.txt' or die $!;
    my $lines = grep 1, <FILE>;
    seek FILE, 0, 0 or die $!;
    $lines -= 20;
    print <FILE>.'' while ($lines--);

Cheers,

Rob




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

Reply via email to