in reply to Cut off beginning lines of a file
If you need to do it in-place rather than by copying the file you could use this:
#! perl -slw use strict; open my $fh, '+<', $ARGV[ 0 ] or die $!; <$fh> while ($.||0) < 32; my $bufsize = tell( $fh ); my( $readPoint, $writePoint ) = ( $bufsize, 0 ); my $buffer; local $/; while( my $read = read( $fh, $buffer, $bufsize ) ) { seek $fh, $writePoint, 0; print $fh $buffer; $writePoint += $read; seek $fh, $readPoint+=$read, 0; } truncate $fh,$writePoint; close $fh;
|
|---|