#! 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: $!"; my $linevalue; while ( $linevalue = ) { $addr = tell(FH) unless eof(FH); last if (eof(FH)); } if($linevalue eq "\n") { truncate(FH, $addr) or die "can't truncate $file: $!"; } exit;