W
Wcool
Hi,
From the chapter on internal workings of Perl in the Perl book, I
think it should be possible to conditionally compile something based
on a variable.
I have the following real problem: my code has a lot of statements
that conditionally print a tracing message.
That is based on a command line parameter.
Is it possible during the compilation phase to NOT generate any code
for those statements if that command line is not set.
Example:
sub Trace
{
my ($debug, $msg) = @_;
if ($debug) {
print $msg."\n";
}
}
sub SomeFunc1
{
Trace($opt_d, 'In SomeFunc1');
....
Trace($opt_d, . 'some_var = '.$var1);
...
Trace($opt_d, . 'some_var2 = '.$var2);
etc
}
If opt_d is not set I like the Perl not to generate any code for it
internally (some sort of skip)
The compiler would go through SomeFunc1 at just don't parse the Trace
statement.
This would increase speed of the program (slightly).
Is this possible?
Thanks,
Jeroen
From the chapter on internal workings of Perl in the Perl book, I
think it should be possible to conditionally compile something based
on a variable.
I have the following real problem: my code has a lot of statements
that conditionally print a tracing message.
That is based on a command line parameter.
Is it possible during the compilation phase to NOT generate any code
for those statements if that command line is not set.
Example:
sub Trace
{
my ($debug, $msg) = @_;
if ($debug) {
print $msg."\n";
}
}
sub SomeFunc1
{
Trace($opt_d, 'In SomeFunc1');
....
Trace($opt_d, . 'some_var = '.$var1);
...
Trace($opt_d, . 'some_var2 = '.$var2);
etc
}
If opt_d is not set I like the Perl not to generate any code for it
internally (some sort of skip)
The compiler would go through SomeFunc1 at just don't parse the Trace
statement.
This would increase speed of the program (slightly).
Is this possible?
Thanks,
Jeroen