Certainly:
sub changelog {
if($GMS->getsetting('OTHER','LOGCLEAR') > param("NOWTIME")){
viewlog("Error: Time-Date mismatch.");
exit;
}
my $filename = $GMS->getsetting('FILE','MEMBERDIRL').'/GMS';
open(logfile,"$filename.log") or $GMS->dienice("Unable to open log
+file!");
flock(logfile,2) if($GMS->getsetting('OTHER','FLOCK'));
my $length = scalar(@{[<logfile>]})-1;
seek(logfile,0,0);
my %lines;
for(my $i = 1; $i <= $length+1; $i++){
$lines{$i} = 1 if(param("LINE$i"));
}
open(tempfile,">$filename.tmp") or $GMS->dienice("Unable to open te
+mporary file!");
flock(tempfile,2) if($GMS->getsetting('OTHER','FLOCK'));
seek(tempfile,0,0);
my $count = 0;
while(my $line = <logfile>){
$count++;
if($lines{$count}){
next;
}else{
print STDERR "$count kept\n";
}
print tempfile $line;
}
close(tempfile);
close(logfile);
rename("$filename.log","$filename.bak") or $GMS->dienice();
rename("$filename.tmp","$filename.log") or $GMS->dienice();
unlink("$filename.bak") or $GMS->dienice();
$GMS->changesetting('OTHER','LOGCLEAR',time);
#The GMS object actually does have a filehandle for the 'logfile' i
+n the object
#however, I have tried manually closing it and there was no differe
+nce.
$GMS->logaction("Removed elements from log file");
viewlog("Changes sucessful!");
}
FYI: This is run under 'strict'
Now, this code actually has one of the filehandles still open, however I had tried manually closing it with no effect...
This is only a bit of the code... but I didn't think anyone would want me to send over 2000 lines of code.
Does this clear anything up?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
------END GEEK CODE BLOCK------
Translate
"Weird things happen, get used to it."
Flame ~ Lead Programmer:
GMS
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.