#! perl -slw use strict; use File::ReadBackwards; my $file = $ARGV[ 0 ]; tie *BW, 'File::ReadBackwards', $file; my $lastpos = -s( $file ); while( ) { last unless /SIL/; $lastpos = tell( BW ) } truncate $file, $lastpos; close BW; #### C:\test>type junk35.dat 0.642375 125 SIL 1.0705 125 ??? 1.3651875 125 ??? 1.519875 125 ? 7.2140627 125 ?? 7.478125 125 ??? 7.622625 125 ?? 7.956125 125 ? 0.642375 125 SIL 1.0705 125 ??? 1.3651875 125 ??? 1.519875 125 ? 7.2140627 125 ?? 7.478125 125 ??? 7.622625 125 ?? 7.956125 125 ? 0.642375 125 SIL 1.0705 125 ??? 1.3651875 125 ??? 1.519875 125 ? 7.2140627 125 ?? 7.478125 125 ??? 7.622625 125 ?? 7.956125 125 ? 8.192375 125 SIL 8.252 125 SIL 8.464 125 SIL 8.706 125 SIL C:\test>junk35 junk35.dat C:\test>type junk35.dat 0.642375 125 SIL 1.0705 125 ??? 1.3651875 125 ??? 1.519875 125 ? 7.2140627 125 ?? 7.478125 125 ??? 7.622625 125 ?? 7.956125 125 ? 0.642375 125 SIL 1.0705 125 ??? 1.3651875 125 ??? 1.519875 125 ? 7.2140627 125 ?? 7.478125 125 ??? 7.622625 125 ?? 7.956125 125 ? 0.642375 125 SIL 1.0705 125 ??? 1.3651875 125 ??? 1.519875 125 ? 7.2140627 125 ?? 7.478125 125 ??? 7.622625 125 ?? 7.956125 125 ?