Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: many files one log file

by glenn (Scribe)
on Dec 04, 2013 at 14:28 UTC ( #1065596=note: print w/replies, xml ) Need Help??


in reply to Re: many files one log file
in thread many files one log file

Just tried it, like i posted, and it worked like a champ thank you so much.
Lib template
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]}; }

MAIN:
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();

sharedFunctions:
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 locate +d at? unless ($sourcepath =~ m/\\$/) { $sourcepath .= "\\"; } #ARRAYS: our @dayofweek = ("Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"); our @monthnames = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "A +ug", "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.ex +e", encrypt => $sourcepath."generateLicenseKey.exe", decrypt => $sourcepath."decryptLicenseKey.exe", }, );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1065596]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2022-01-16 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (49 votes). Check out past polls.

    Notices?