Thread: Perl code
View Single Post
Old 08-24-2002, 11:23 AM  
kenny
Confirmed User
 
Industry Role:
Join Date: Mar 2002
Posts: 7,245
Quote:
Originally posted by FuqALot
Yo,

$file = "x.txt";
open(logfile,"+<".$file);
flock logfile, 2;
@logdata = <logfile>;
seek logfile, 0, 0;
print logfile $newline."\n";
print logfile @logdata;
truncate logfile, (tell logfile);
close(logfile);

is the way. Where $newline is the entry, and $file the logfile.

open(LOG,"+<".$log);
flock LOG, 2;
@logdata = <log>;
seek LOG, 0, 0;
print LOG '<TR><TD>';
print LOG @group[1];
print LOG '</TD>';
print LOG '<TD><A HREF=';
print LOG @url[1];
print LOG '>';
print LOG @description[1];
print LOG '</A></TD></TR>';
print LOG "\n";
print LOG @logdata;
truncate LOG, (tell logfile);
close(LOG);

This worked like a charm, I liked the reverse open idea just couldnt get it to work.

Thanks everyone


kenny is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote