#!/usr/bin/perl -w use strict; open (IN,"blah.file")||die ("Failed to open file blah.file\n$!"); open (OUT,"blah.file.nospace")||die("Failed to open file blah.file.out for writing\n$!"); my $count=0; while () { chomp $_; if ($_=~m/^$/g) { $count++; } else { print OUT "$_\n"; } } close IN; close OUT; print 'Deleted '."$count".' blank lines'."\n"; exit (0); #### if ($_=~m/^$/g) { #### if ($_=~m/^\s*$/g) {