On Saturday 14 Dec 2002 8:51 am, christopher j bottaro wrote:
> yes...thank you.  i was going to post exactly that, but didn't know how to
> phrase it.  i'm very capable of producing a script/program in whatever
> language that reads a line from input, edits the line, then writes the
> edited line to a new file (or stdout or whatever).  but like Jim said, the
> question is can it be done in situ without duplicating most of the file?  i
> guess it can't.

Sorry, I didn't read your OP properly but I did have to read it 3 times just 
now.  You basically ask how to do something then say it can't beq done.

Actuallty it can be done, but yo need to ask yourself which is more important 
- performance and time, or disk space used?

If it's performance and time then my script is best, as it will have more 
efficient IO mainly because of most OS's optimisation for sequential reading 
using read-ahead buffers etc.

If the most important aspect is disk space - e.g. you have a 10MB file to edit 
but only 5MB of disk space, then your only option is in-situ updating.  
Because you are removing characters and not inserting them you can do this 
but yo are right when you say that you will have to shuffle the characters.

Although I won't have a go right now, basically you will need to use two 
pointers, one for reading, one for writing and then truncate the file when 
you've finished.

Have a look at

perldoc -f seek
perldoc -f tell
perldoc -f truncate.

If you need any more help, come back up me.

>
> On Saturday 14 December 2002 03:01 am, you wrote:
> > On Friday 13 December 2002 12:18, Gary Stainburn wrote:
> >
> > This still doesn't answer his question.  He doesn't want to take up 20
> > Mb's of hdd space trying to do the edit. :)
> >
> > btw, in a regex \r\n works fine. :)

I never said that it wouldn't, I just prefered the use of chomp because this 
way it was easy to convert in either direction with minimal coding.

> >
> > - Jim

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


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

Reply via email to