in reply to Delete last record in text file

you can also use Tie::File:
#!/usr/bin/perl -w use strict; use Tie::File; my $filename = 'file.txt'; tie my @data, 'Tie::File', $filename or die "couldn't tie(): $!"; pop @data; untie @data;

hope this helps,

Replies are listed 'Best First'.
Re: Re: Delete last record in text file
by wirrwarr (Monk) on Aug 18, 2003 at 18:14 UTC
    Tie::File seems to be rather slow on large files. I tried the Tie::File and (open file, read in all lines, pop, write back) variants on a ~5M file, and the second was about 10 times faster.