package PKG;
use strict;
use sharedFunctions;
my $LOGFH = undef;
my $writelog = undef;
#constructor
sub new {
my ($self) = {};
bless($self);
return $self;
}
sub import {
shift;
$LOGFH = ${$_[0]};
$writelog = ${$_[1]};
}
####
use sharedFunctions; #$files{log}{file} => logfile.log
my $writelog = Thread::Semaphore->new(); #sequential log writing
open my $LOGFH ,">", $files{log}{file};
#disable write buffer
my $stdout = select($LOGFH);
$| = 1;
select($stdout);
require PKG;
PKG->import(\$LOGFH, \$writelog);
my $pk = PKG->new();
##
##
package sharedFunctions;
use warnings;
use strict;
use File::Basename;
use Cwd;
use Data::Dumper;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw($hexdec $sourcepath @dayofweek @monthnames %files);
#SCALERS:
our $hexdec = "[0-9a-fA-F]";
our $sourcepath = dirname(Cwd::abs_path(__FILE__)); #Where am I located at?
unless ($sourcepath =~ m/\\$/) {
$sourcepath .= "\\";
}
#ARRAYS:
our @dayofweek = ("Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat");
our @monthnames = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
#HASHES:
our %files = (
file1 => $sourcepath."jobstatus1.txt", #XML test status files for recovery
file2 => $sourcepath."jobstatus2.txt", #XML test status files for recovery
logfile => $sourcepath."diag.log",
reports => $sourcepath."Report\\",
config => $sourcepath."diagConfig.dat",
station => $sourcepath."station_number.txt",
hardware => $sourcepath."hardware_details.xml",
update => $sourcepath."perlupdate.log",
source => $sourcepath."SOURCE",
temp => $sourcepath."TEMP.txt",
log => {
file => $sourcepath."diag.log",
fileNameLen => -22.22,
funNameLen => -21.21,
lineNumLen => 5,
timeLen => 24.24,
},
license => {
temp => "lic.temp",
encryptLicenseInfo_utility => $sourcepath."generateLicenseKey.exe",
decryptLicenseKey_utility => $sourcepath."decryptLicenseKey.exe",
encrypt => $sourcepath."generateLicenseKey.exe",
decrypt => $sourcepath."decryptLicenseKey.exe",
},
);