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

Re: [MacPerl] deleting a line again



>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?

 Maybe I'm missing something, but to be honest the only advantage  I can
see to wanting to do this kind of operation would be to save time because
the volume of files to be changed is simply enormous and the machine you
want to use is incredibly slow. If this is the case then maybe you should
consider upgrading your hardware :-). I've done bulk substitutions on large
groups of files (up to 10Mb) by simply opening each file and over writing
the file whilst excluding/substituting the offending line/data. so if the
file looks like this:

>   #this is the line you don't want
second line
third line ...

simply using a test for the offending char to stop it from being written
back to the new file should suffice:

#! -w

open (IN, "PATH_TO_SOURCE_FILE");
open (OUT, "PATH_TO_DEST_FILE");

while (IN){
	unless $_=~/^>/ {
	print OUT $_,"\n";
	}
}
_END_

OUTPUT:
second line
third line ...



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