Hi,

If $date is present in my log then I want to add something to the end of 
the same line. If it is not present I want to insert the date on a new line 
and add stuff to the end. If present, $date will always be in the last line 
of the log.

I have tried all kinds of things, but I cannot get it to work properly. The 
print statements are not being executed. I believe the below code to be the 
most correct what I have come up with so far. Perl -w does not give an 
error that the log is not yet open. That seems to be okay. See below for 
the format of the output log.

What I am doing wrong here?


### begin code snippet ###

open (LOGFILE, "+>>$resultlog") || die "cannot open $resultlog\n";
while (<LOGFILE>) {
        if (/$date/) {
                print "date found: script has run before today\n";              
                measurement ();
                print LOGFILE ("\t", "$hour:$min", "\t", "$bandwith");
        } # end if.
        else {
                print "date not found: inserting date\n";
                measurement ();
                print LOGFILE ("\n", "$date", "\t", "$hour:$min", "\t", "$bandwith");
        } # end else.
} # end while.
close (LOGFILE);

### end code snippet ###

Sample output log:
2001-08-03      10:23   4,56    15:14   5,01    21:45   6,21
2001-08-04      10:23   3,98    15:15   1,21    21:45   6,18
2001-08-05      10:23   4,14

In this example $date would be 2001-08-05


Thanks in advance,
Louis. 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to