debug stmts; cmd line define

M

Mike Ballard

Been looking around usenet and am not finding what I'm looking for; how do
I put statements in perl code for debug only (like printfs or whatever)
and then actvate/define them from the command line? I know using cpp I
can "-D<>" for ifdef statements and am looking for the same kind of thing
for perl.

Mike
--
 
A

Anno Siegel

Mike Ballard said:
Been looking around usenet and am not finding what I'm looking for; how do
I put statements in perl code for debug only (like printfs or whatever)
and then actvate/define them from the command line? I know using cpp I
can "-D<>" for ifdef statements and am looking for the same kind of thing
for perl.

Here is one way. In file "program", write

print "debugging\n" if defined &DEBUG and DEBUG();

Run with "perl program", this prints nothing.
Run with "perl -Mconstant=DEBUG,1" program", it prints "debugging".

Anno
 
M

Mike Ballard

Here is one way. In file "program", write

print "debugging\n" if defined &DEBUG and DEBUG();

Run with "perl program", this prints nothing.
Run with "perl -Mconstant=DEBUG,1" program", it prints "debugging".

Thank you very much; just what I was looking for...

Mike
--
 
B

bugbear

Mike said:
Been looking around usenet and am not finding what I'm looking for; how do
I put statements in perl code for debug only (like printfs or whatever)
and then actvate/define them from the command line? I know using cpp I
can "-D<>" for ifdef statements and am looking for the same kind of thing
for perl.

If you're doing anything of "significant" you might try:
http://log4perl.sourceforge.net/

BugBear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top