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

Re: [MacPerl] deleting a line again



On 2/8/00 at 5:58 PM, Andy Berkvam wrote:

: On Tue, 8 Feb 2000, george rosenberg wrote:
: 
: > let me explain further, what I am probably trying to ask:
: > almost always, the line i want to remove is the first line in the 
: > file and it begins with a ">".
: > i want to remove this line and then close the file.
: > 
: > is it possible to do this? is there a delete line command, that will 
: > remove the line and not leave a empty line behind?
: >
:   Matthias did answer your question.  Computers don't think in terms of
: "lines" in a filesystem.  Therefore you have to do the work yourself.  
: What you are asking for is not possible.
: 
: 


Well, it's not really a problem as you say of lines, but of bytes.  The answer
would be the same if the question were "How can I delete the first 10 bytes of the
file without reading in the entire file?"

The reason has to do with how files are stored in blocks on the disk.  Each block
is a multiple of some number, usually 512 or 1024 bytes.  If each block is a known
size, it is easier for the file system to keep track of the location of the file. 
In order to delete the first x bytes of a file, the file system would have to be
able to keep track of not only the block's location, but the offset into that
block, or the file system would need to have some sort of low level call that
would copy the file x bytes bytes up to the start of the block.  Either of these
otions would make the directory bigger and the hardware's programming more
complex.  This is not something that can be done from Perl, it would have to be
implemented in the OS or on the disk drive itself.

Don



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org