--- COLLINEAU Franck FTRD/DMI/TAM <[EMAIL PROTECTED]> wrote:
> Hi!
>
> How can i do to delete the last line of a file ?
>
> Thanks
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
Try:
#Get the data
open(FILE, $file) or die "Couldn't open $file: $! \n";
my @FileData = <FILE>;
close(FILE);
#How many lines:
my $HowMany = @FileData;
#Make sure you have something
if($HowMany > 0) {
#remove last line
pop@FileData;
#write back to the file
open(FILE, ">$file") or die "Couldn't open $file: $! \n";
print @FileData;
close(FILE);
}
Of course you can do more checking and verification
Greg
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]