truncate('test.dat', 1024); #### use strict; use warnings; my $fname = 'test.dat'; my $crop = 1024; my $handle; open($handle, $fname); $_ = (stat($handle))[7]; if ($_ > $crop) { seek($handle, $_ - $crop, 0); read($handle, $_, $crop); close($handle); open($handle, ">$fname"); print $handle $_; } close($handle); #### my $crop = 1024; my $margin = 64; ... read($handle, $_, $crop + $margin);