Ok. I'm pulling my hair out. I know I've written code just like this years ago but my perl has grown rusty. Anyway, simple debug routine that takes 4 arguments - a string and 3 numeric flags.
I call this function and depending upon where I want the output to go I set the 3 flags
debug("WARNING: blah blah", 1, 0, 0);
Here is the function (and yes I define a function prototype for this):
Code:
sub debug($$$$) {
if ($DEBUG != 1) { return; } # DEBUG is a global var
my $_mesg = shift;
my $_f1 = shift; # STDOUT
my $_f2 = shift; # STDERR
my $_f3 = shift; # LOGFILE
if ($_f1 == 1) {
printf STDOUT "%s : %s\n", localtime(), $_mesg;
return;
}
if ($_f2) {
sleep 1; # STUB
}
if ($_f3) {
sleep 1; # STUB
}
return;
}
Here is sample output:
55 : 12
56 : 12
58 : 12
Why is my message displaying as 12
I'm sure this is something stupid, or my lack of sleep but right now this eludes me.
And yes, I know there are hundreds of debug modules I can use but this is concise and simple for what I need this to do. Data:
umper and similar modules are overkill for what I want to do here.
Thx