# File: fileDelBlanks.pl # Title: Read a text file and delete empty lines. # Author: Mihaela Malita # use symbols: first char(^) and last char($) # Here is the file names.txt, has comment lines(lines that start with #) and empty lines # # File with names # # # Mary # John # Evan my $filename; my $line; print "Name of the file (names.txt)? "; $filename = ; chop($filename); #read from keyboard unless (open(IN,"$filename")) { #check if the file exists print "No file with such a name!"; exit; } $line = ; #reads line by line the text file until End Of File (EOF) $line =~ s/^\s/g) ; # skip empty line ^\s*$ first char(^) and last char($) print $line; close IN; exit;