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

Re: [MacPerl] deleting a line again



Hi George,

As lots of people have pointed out, this isn't possible in general.  BUT, if
you're totally unwilling to rewrite the file and you're willing to modify your
requirement, you might consider _replacing_ the first line (all bytes until the
first newline) with other characters like spaces, or special characters.  The
program that reads the file can then just skip past all these characters and
jump to the new first line.

This might not be an option for you, perhaps the file has to be "just so."  But
it's an idea.

Anyway, to implement it, open the file for writing without clobbering it, seek
to the beginning, then just print some bytes to the file.


ghrose@unm.edu (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?
>
>thanks
>
>
>
>>  >i would like to use Macperl to remove a single line from a "big
>>>bunch" of files without leaving a blank line behind.  is it possible
>>>to do this without rewriting the whole file? is there a command or
>>>short code that can do this once the line has been indentified?
>>
>>Sorry, no, that's not how file systems work (When I was young, even 
>>the concept
>>of being able to jump to an arbitrary position in an open file was
>>revolutionary :-)
>>
>>Matthias
>>
>>--
>>Matthias Neeracher   <neeri@iis.ee.ethz.ch>  
http://www.iis.ee.ethz.ch/~neeri
>>   "And that's why I am going to turn this world upside down, and make
>>    of it a fire so *bright* that someone real will notice"
>>                                 -- Vernor Vinge, _Tatja Grimm's World_
>
>-- 
>
># ===== Want to unsubscribe from this list?
># ===== Send mail with body "unsubscribe" to macperl-request@macperl.org
>

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



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