Under w2k I was unable to do an inline update without some type of
backup.  Tried from command line and korn shell.  If I did this:

perl -p -i.plsdel -e "s/^\s*\n//" 03WorkSheet.txt
 which would create a copy with the name 03WorkSheet.txt.plsdel and
03WorkSheet.txt would be without the blank lines.

        I tried the oneliner with "redo if ..." but it only hung on me, so
unsure what I was happening there.

        This makes a copy, but if you give it an extenion of .plsdel then
you could find on that and delete those with a similar one liner:

find . -name '*.orig' -print0 | perl -n0e unlink
        Per the doc, the find needs the ability to write binary 0 which
worked under the korn shell, but did not under the cmd.exe

        This was taken from the doc on ActiveState under perlrun

        I tried the above the on mortice-kern korn shell and the two
commands did the change and the cleanup.

        A start.

Wags

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


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]


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


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

Reply via email to