Delete blank lines from a file

Hi,
I want to use diff to compare two files in a Perl file. But one of the files has some blank lines at the end. So I want to delete the blank lines from the file firstly and then use diff to compare them. But I dont know how to delete the blank lines from the files. Meanwhile, the system is solaris 10.
Is there a Perl Module that can compare the files?
So far as I known, the File::Compare can compare the files, but it can not ignor the blank lines, space, tab, etc.
can you help me out of this?

Thanks and Best Regards
Damon

You can use sed for that.

sed '/^$/d' your_file > new_file
mv new_file your_file

tyler_durden

thanks anyway
is there any other good ideas? I dont want to solve the problem like this.

Ok, would you like to perform inline editing ?
You can use the "perl pie" technique for that -

$
$
$ cat -n f0
     1  line no. 1
     2  line no. 2
     3  line no. 3
     4
     5
     6
$
$
$ perl -pi.bak -e 's/^\s*$//' f0
$
$ cat -n f0
     1  line no. 1
     2  line no. 2
     3  line no. 3
$
$
$

tyler_durden

clean empty line directly from the input file

vi -c "g/^$/d" -c "wq"  urfile

If you have a diff that supports -B, then you can use that:

From the diff man page: