Labelle, Marc S wrote:
Hello all,
I'm a bit confounded by the error I'm getting.
I've got a small subroutine (listed below) that I call when I need to
post data to both the console and a logfile.
It is using two globals and one variable passed to it (globals are a
flag to enable/disable the logfile, and the filehandle).
It's a dead simple subroutine and I don't know what I'm doing wrong.
Basically the script interfaces to some National Instruments hardware
(which is working fine) and iterates over several options (also
working fine). As it goes it logs results, data, etc.
Periodically and **not** at the same point in the program each time
the script will fail with an "undefined subroutine &main::sLogData",
this after it's successfully called it 20 or 30 times before...
Any thoughts?
Cheers,
-Marc
sub sLogData(@)
{
my $string=$_[0];
print "$string";
if ($flag_log) {print LOGFILE "$string"; }
return(0);
}
---------
Looks like one of those working fine routines is calling the log
function with a null string breaking the prototyping.
Here is my tests and results.
#!/perl
use warnings;
use strict;
my $flag_log;
sub sLogData(@)
{
my $string=$_[0];
print "$string";
if ($flag_log) {print LOGFILE "$string"; }
return(0);
}
open(LOGFILE,">LOGFILE.TXT");
$flag_log=1;
sLogData("Test string 1\n");
sLogData("");
sLogData("Test string 2\n");
SLogData();
sLogData("Test string 3\n");
Results:
----------------
Test string 1
Test string 2
Undefined subroutine &main::SLogData called at play.pl line 19.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs