I can think of two ways:

if your system implements truncate you can say:

open IN, $file or die "$file:$!";
$temp = <IN>;                # don't throw away first line;
print <IN>;                  # print the rest of the file.
truncate IN, length($temp);  # only keep the first length($temp) bytes

or the more portable:

open IN, $file or die "$file:$!";
$temp = <IN>;                          # don't throw away first line;
print <IN>;                            # print the rest of the file.
close IN;                              # get rid of the filehandle
open OUT, "> $file" or die "$file:$!"; # replace file
print OUT $temp;                       # stick first line back in
close OUT;                             # flush the file 

On 01 Jun 2001 16:17:06 -0500, Nichole Bialczyk wrote:
> so how do i delete the lines that i read in? (keeping the first one so 
> that the file still exists)
> 
> On Fri, Jun 01, 2001 at 02:08:25PM -0700, Paul wrote:
> > 
> > --- Nichole Bialczyk <[EMAIL PROTECTED]> wrote:
> > > to be more specific, i want to do this: read and delete all of the
> > > lines  from a log file, except for the first one.
> > 
> >  open IN, $file or die "$file:$!";
> >  <IN>;        # throw away first line;
> >  print <IN>;  # print the rest of the file.
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail - only $35 
> > a year!  http://personal.mail.yahoo.com/

-- 
Today is Boomtime, the 6th day of Confusion in the YOLD 3167
Hail Eris!


Reply via email to