The only thing I know of that will change the curretn file is a combonation of som 
eunix commands like


This takes three lins but I seem to remember doing it in one.

Test it out on the command line and if you can get it to do what you want just do that 
command in backticks :
print `cat ....`;


@lines_that_have_stuff = `cat $filename | sed ... `; # I can't remember the exact sed 
bit see 'man sed'

print `echo > $filename`;  

foreach $line(@lines_that_have_stuff) { print `echo $line >> $filename`; }


-----Original Message-----
From: Timothy Johnson [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, January 08, 2003 11:25 AM
To: 'Rob Dixon'; [EMAIL PROTECTED]
Subject: RE: removing emty lines without creating a new file or array



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]


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

Reply via email to