[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Perl realted question..



On Wed, Jan 09, 2008 at 10:04:19PM -0500, ISHWAR RATTAN wrote:
>
> Is there a way to place the last line read
> when reading from a file? My suspicion is there
> is no such thing but i do want to confirm..

Just another guess at what you're asking about; perhaps the word
"placed" was intended to be "replaced"; i.e., can you replace a
line that you've just read?

I think the general answer to that is "no", and the approach I've
always taken (using Perl) is to write a new file, copying the old
and adding new content, then rename and remove etc. when done.  I
haven't delved into the internals much, though, and maybe there's
a way it could be done, but it hasn't been worth my time to do it.

If you think about a file stored on disk, text files have an arbitrary
structure defined by the end-of-line character(s).  It seems like
it should be possible to swap out characters in a line, but the line
size would need to stay the same, perhaps using padding with spaces
or something.  Probably much more reasonably and conventionally doable
with fixed-sized records, but if the need was there I don't see why
it shouldn't be possible.

Ken

-- 
Ken Irving, fnkci+debianuser@uaf.edu


Reply to: