Hi All,
I have a perl module TrxLog.pm and following are codes in it
#!/usr/local/bin/perl
package TrxLog;
%log_begin="";
%log_end="";
%log_msg="";
%log_start_time="";
%log_end_time="";
$ix=0;
@arr_msg="";
if (! -e "TrxLog.txt"){
open (TRX,">TrxLog.txt");
}else{
open (TRX,">>TrxLog.txt");
}
sub begin{
my($parm)=@_;
$log_start_time{$parm}=localtime(time());
$log_begin{$parm}=time();
$log_msg{$parm}="** $parm Process **";
}
sub end{
my($parm)=@_;
$log_end_time{$parm}=localtime(time());
$log_end{$parm}=time();
my($msg)=$log_msg{$parm};
my($diff)=$log_end{$parm} - $log_begin{$parm};
my ($tsec,$tmin,$thour,$tmday,$tmon,$tyear,$twday,$tyday,$tisdst) =
gmtime($diff);
print TRX "$msg\n\n";
print TRX "\n";
print TRX "\tStarted at $log_start_time{$parm}\n";
print TRX "\tFinished at $log_end_time{$parm}\n";
print TRX "\tElapsed Time Hours:$thour";
print TRX " Minutes:$tmin";
print TRX " Seconds:$tsec\n";
$ix=0;
while ($arr_msg[$ix]){
print TRX "$arr_msg[$ix]\n";
$ix++;
}
&close_log;
}
sub log_trx{
my($msg)=@_;
$arr_msg[$ix]=$msg;
$ix++;
}
sub close_log{
print TRX "**************** End of Session **************************\n\n";
close TRX;
}
1;
My problem is
The below log produced by a perl script is correctly appended into the TrxLog.txt file
** DNB Load Process **
Started at Mon Nov 10 14:09:13 2008
Finished at Mon Nov 10 14:11:04 2008
Elapsed Time Hours:0 Minutes:1 Seconds:51
archival of dnb process started
archival dnb_20081101 table created & total rows :520940
62507 DNB inserted
**************** End of Session **************************
But When I used the same perl module TrxLog.pm in another perl script it produced the following log.Which is not complete.
Started at
Finished at Mon Nov 10 15:53:08 2008
Elapsed Time Hours:20 Minutes:53 Seconds:8
**************** End of Session **************************