[Chicago-talk] removing line from file.

Wiggins d'Anconia wiggins at danconia.org
Wed Mar 9 11:27:55 PST 2005

Richard Reina wrote:
> This may be annoyingly simple for most on this list,
> but does someone have time to take a minute to tell me
> what the easiest way in perl 5 to remove the first
> four lines from a text file?
> Thanks for any help.
> Richard

If you aren't on the command line, one solution,

use strict;
use warnings;

use Fcntl "O_RDWR";
use Tie::File;

tie my @file, 'Tie::File', 'test.txt', mode => O_RDWR or die "Can't tie 
file: $!";

splice @file, 0, 4;

untie @file;


More information about the Chicago-talk mailing list