#! 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;