Gossamer Forum
Home : General : Perl Programming :

Need Help Removing Line From File

Quote Reply
Need Help Removing Line From File
Hello,
I need help with removing the first line of a file. Can anyone help me?

------------------
Quote Reply
Re: Need Help Removing Line From File In reply to
Im not using a I/D based database.

------------------
Quote Reply
Re: Need Help Removing Line From File In reply to
You can find such a routine in delete routine in db.pl or db_utils.pl of Links2.0.

Hope this helps...
Quote Reply
Re: Need Help Removing Line From File In reply to
Then try the following:
-make an array, by splitting by \n
-shift that array
-print that array to file

...and you're ready!
Quote Reply
Re: Need Help Removing Line From File In reply to
Or check out subscribe.cgi for a delete routine without an ID.
Quote Reply
Re: Need Help Removing Line From File In reply to
How bout:

open (IN, "<input.txt") or die $!;
open (OUT, ">output.txt") or die $!;
$junk = <IN>;
while (<IN> ) {
print OUT;
}
close IN;
close OUT;

you now have a copy of the input file in the output minus the first line. Do a rename() to overwrite the file.

Cheers,

Alex