It doesn't look to me like there can be much wrong with the sub.
I tend to use the following sort of construct instead of the IF test,
however:
$flag_log and print LOGFILE "$string";
I would guess that the problem has more to do with the environment that the
sub is being called from than the sub itself.
--Geoff
On Mon, Jun 30, 2008 at 2:25 PM, Labelle, Marc S <[EMAIL PROTECTED]>
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);
>
> }
>
>
>
>
>
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
--
--Geoff
Cell: (313)506-7295
Sterling Heights CERT
'04 Grand Cherokee | '05 Town & Country
http://www.moparmailinglist.com
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs