[plug] perl program to strip blank lines from a file

J Michael Gilks mike at gilks1.com
Tue May 18 04:19:39 WST 2004


RegEx needs to find any whitespace on a blank line, so
/^\s$/
will do the trick.

Love
Mike.

On Mon, 17 May 2004 03:36 pm, David Buddrige wrote:
> Hi all,
>
> I am tryin to put together a program which will strip blank lines out of a
> text file.  To this end, I have written the following perl program; but it
> doesn't seem to work... can anyone see why?  To my mind, the regex ^$
> should match lines that have no content, but this does not seem to be so...
>
> any help greatly appreciated...
>
> #!/usr/bin/perl
>
> while(<>)
> {
>    if(/^$/)
>    {
>    }
>    else
>    {
> 	print;
>    }
> }
>
> thanks
>
> David.
> _______________________________________________
> PLUG discussion list: plug at plug.linux.org.au
> http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug
> Committee e-mail: committee at plug.linux.org.au



More information about the plug mailing list