#! usr/bin/perl opendir(FILES,".")||die "Cannot open files in the directory\n"; @files=(); for(readdir(FILES)){ if($_=~/\.txt/){ push(@files, $_); } } print "@files\n"; for $i(0..$#files){ print "working on $files[$i]\n"; open (FH, "+<$files[$i]") or die "can't update $file: $!"; while ( ) { $addr = tell(FH) unless eof(FH); } truncate(FH, $addr) or die "can't truncate $file: $!"; } exit;