Y
Yash
I have a Perl program that processes millions of records, and hence
has to be efficient. However, during development and testing, we do a
lot of logging to a file for debugging.
The code has a lot of statements such as:
diagnostic("Input line is");
diagnostic($inputLine);
The function is defeined as:
sub diagnostic
{
if ( $DIAGNOSTICS == 1 )
{
printf LOGFILE $_[0];
}
}
When this same program is shipped and executed on the client's system,
even if the $DIAGNOSTICS value is set to 0, the condition checks are
still done, just that no message is logged.
I would ideally like to instruct Perl not to compile any code related
to the diagnostic statements. Is there a way to specify compiler
directives to Perl as is done in C++ compilers?
In c++ I would compile using
cc .... -DDIAG. The code would have
#ifdef DIAG
diagnostic code
#endef
I know Perl is interpreted, but it still does compilation before
running. Is there some way I can pass an argument so that I make it
compile without diagnostic messages?
Thanks
has to be efficient. However, during development and testing, we do a
lot of logging to a file for debugging.
The code has a lot of statements such as:
diagnostic("Input line is");
diagnostic($inputLine);
The function is defeined as:
sub diagnostic
{
if ( $DIAGNOSTICS == 1 )
{
printf LOGFILE $_[0];
}
}
When this same program is shipped and executed on the client's system,
even if the $DIAGNOSTICS value is set to 0, the condition checks are
still done, just that no message is logged.
I would ideally like to instruct Perl not to compile any code related
to the diagnostic statements. Is there a way to specify compiler
directives to Perl as is done in C++ compilers?
In c++ I would compile using
cc .... -DDIAG. The code would have
#ifdef DIAG
diagnostic code
#endef
I know Perl is interpreted, but it still does compilation before
running. Is there some way I can pass an argument so that I make it
compile without diagnostic messages?
Thanks