I want to remove blank lines (empty or with spaces and tabs) from a file from within a perl script.
here's what i tried.

`sed '/^ *\$/d' $file1`;

Does not seem to work for some reason.
Any Help please?

Take out the space (unless you are looking for lines with just one space)


So, given a file called test.txt, JUST the sed part would be:

sed '/^$/d' test.txt

...or if you just want to do it from the command-line

perl -pi -e "s/^\n//" test.txt

thanks for your replies. $^ matches a blank line(but not a line with spaces). I eventually ended up calling the perl inline from my script. :)