SPUG: re:humble print statement for debugging

Kristi Anderson kanderson at nwadmin.com
Mon Mar 22 13:18:01 CST 2004

Hi all,

I've just recently added perl to the list of languages of which I know just enough to be dangerous.  One thing I've noticed about all of them is that you can almost always easily figure out how to use print or show or display or printf or cout, but to learn the debugger of each is considerably more time consuming.


 -----Original Message-----
From: 	spug-list-request at mail.pm.org [mailto:spug-list-request at mail.pm.org] 
Sent:	Friday, March 19, 2004 10:01 AM
To:	spug-list at mail.pm.org
Subject:	spug-list Digest, Vol 9, Issue 15

Send spug-list mailing list submissions to
	spug-list at mail.pm.org

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
	spug-list-request at mail.pm.org

You can reach the person managing the list at
	spug-list-owner at mail.pm.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of spug-list digest..."

Today's Topics:

   1. Fwd: Re: SPUG: Last night's meeting (Marc M. Adkins)
   2. Re: Fwd: Re: SPUG: Last night's meeting (Michael R. Wolf)


Message: 1
Date: Thu, 18 Mar 2004 17:10:56 -0500
From: "Marc M. Adkins" <Perl at Doorways.org>
Subject: Fwd: Re: SPUG: Last night's meeting
To: Seattle Perl Users Group <spug-list at pm.org>
Message-ID: <200403181710.56598.Perl at Doorways.org>
Content-Type: text/plain;  charset="iso-8859-1"

>> Condemn all debug print statements now!
> IMHO, the humble print statement has a significant advantage over
> any interactive-debugging based strategy, which is simply that it
> will still be there if/when the program breaks again, and it can
> easily be re-activated to deliver its benefits again.
> AFAIK, there's no way to preserve the activities of an
> interactive debugging session, and replay them at a future time.

I have a (Filter::Util::Call) filter that I've been using for a number of
years to turn trace statements embedded in comments on and off.  I can turn
on individual trace statements or blocks of trace statements by keyword or by
subroutine with only a few keystrokes.

	use Trace	qw(KEYWORD);

	#!#	warn "Trace statement off\n";
	#*#	warn "Trace statemetn on\n";
	#!#	warn "Trace statement w/keyword on\n";	#[KEYWORD]
	#!#	warn "Trace statement w/keyword off\n";	#[WRONGWORD]

	sub	function
	  #!#	warn "Trace statement off\n";
	  #$#	warn "All remaining trace statements in routine on\n";
	  #!#	warn "Trace statement on\n";

Since it's a filter, when they're off they're just comments and so there is
_no_ run-time cost.  I can leave them in the code forever.
It's remarkable how few lines of code this is (even w/o Filter::Simple) and
how powerful it is in practice.

And yet...I hesitate sometimes to mention it in 'polite' company because
 there seems to be a subtle prejudice in favor of debuggers of infinite power
 among "real" programmers.  Hummph. [sic]  I get a lot of mileage from the
 humble print statement.



Message: 2
Date: Fri, 19 Mar 2004 00:01:08 -0800
From: "Michael R. Wolf" <MichaelRWolf at att.net>
Subject: Re: Fwd: Re: SPUG: Last night's meeting
To: spug-list at mail.pm.org
Message-ID: <uu10luuyj.fsf at att.net>
Content-Type: text/plain; charset=us-ascii

"Marc M. Adkins" <Perl at doorways.org> writes:


> And yet...I hesitate sometimes to mention it in 'polite' company because

We're not *that* 'polite' -- I prefer to think we're respectfully
courteous, yet not quite tame -- but thanks for the compliment. :-)


>  humble print statement.

The debugger of infinate power?

Michael R. Wolf
    All mammals learn by playing!
        MichaelRWolf at att.net


spug-list mailing list
spug-list at mail.pm.org

End of spug-list Digest, Vol 9, Issue 15

<  Disclaimer  >
Confidentiality Statement-This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to which they are addressed. This communication may contain material protected by HIPAA, ERISA, other federal or state law or the attorney-client privilege. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. You are instructed to destroy the message and notify Northwest Administrators by immediate reply that you have received this e-mail and any accompanying files in error. Please bring any questions you may have on this instruction to the attention of Northwest Administrators immediately. Northwest Administrators does not accept responsibility for changes to e-mails that occur after they have been sent.

More information about the spug-list mailing list