sub lwrite{ my($self,$msg,$value)=@_; # args == object, message and optional value my $FH=*{$$self{FILEHANDLE}}; # Make a filehandle string from the blob my $tstamp; format $FH = ^<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $tstamp, $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $msg . # Get the local time into an array my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time()); my @wdays = qw(Sun Mon Tue Wed Thu Fri Sat); # Make an array of weekday names my $weekday = $wdays[$wday]; # Get today's weekday name $year = $year + 1900; # Calculate the current year $mon = $mon + 1; # Calculate the current month # Now format the message with a time stamp in front of the message $tstamp = sprintf("[$weekday %4d-%02d-%02d %02d:%02d:%02d]", $year, $mon, $mday, $hour, $min, $sec); if(! write $FH ){ # Log it if we cannot print to the file $self->log("Unable to write to $$self{LOG}: $!\n"); } print "\n$msg \n" if ($value ==1); # Print to monitor as well if value == 1 } sub log{ my ($self,$error,$value)=@_; # Args == object, error message and value $self->clear; # Clear last error from the object $$self{ERROR}=$error; # Add the error message to the object push @{$$self{HISTORY}},$error; # Push the error into the history array carp "$error\n" if $$self{CARP}; # Carp if an error with this object $self->lwrite($error,$value); # Send the message and value to "lwrite" sub above }