Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   debug stmts; cmd line define (http://www.velocityreviews.com/forums/t895262-debug-stmts-cmd-line-define.html)

Mike Ballard 11-20-2005 10:38 PM

debug stmts; cmd line define
 

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
--






Anno Siegel 11-20-2005 10:51 PM

Re: debug stmts; cmd line define
 
Mike Ballard <dont_w@nt_spam.org> wrote in comp.lang.perl.misc:
>
> 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
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

Mike Ballard 11-20-2005 11:38 PM

Re: debug stmts; cmd line define
 

On Sun Nov 20, I was peacefully napping until Anno Siegel said:

> Mike Ballard <dont_w@nt_spam.org> wrote in comp.lang.perl.misc:
> >
> > 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".
>


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

Mike
--

bugbear 11-21-2005 02:51 PM

Re: debug stmts; cmd line define
 
Mike Ballard wrote:
> 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

bugbear 11-21-2005 02:52 PM

Re: debug stmts; cmd line define
 
Mike Ballard wrote:
> 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.


Addendum:

http://www.perl.com/pub/a/2002/09/11/log4perl.html

BugBear


All times are GMT. The time now is 02:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.