Except that it will essentially create a new file.  Why did you want to
avoid writing a new file?  As far as I know, you can't just "erase" data in
the middle of a file.  That's just not how they work.  Someone correct me if
I'm wrong.  As far as I know, any program that does this rewrites the file.
The only thing that is somewhat similar is that you can do a sysread and
change part of a file, but I don't think you can remove part of a file
without rewriting it.

-----Original Message-----
From: Rob Dixon [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 9:20 AM
To: [EMAIL PROTECTED]
Subject: Re: removing emty lines without creating a new file or array


Hi Konrad

Try:

    perl -p -i -e "redo if /^\s*$/" file.ext

which will remove all lines consisting only of whitespace.

Cheers,

Rob

"Konrad Foerstner" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> My problem today ;) : I have a file with some unmeant empty lines and I
> want to remove them, without writing a new file and without storing all
> the content temporarily in an array. I thought about the following lines
> of code, but they don't do the job.
>
>
> open (FH, "+<$filename");
>
> foreach (<FH>){
>     $_ =~ s/^\n//g;
> }
>
>
> What's wrong?
>
> Konrad



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to