http://www.perlmonks.org?node_id=377231


in reply to Re: brian's Guide to Solving Any Perl Problem
in thread brian's Guide to Solving Any Perl Problem

I use warn() for program warnings rather than debugging output.

However, if I'm doing really big things, I usually have a debug() or trace() function lying around.

--
brian d foy <bdfoy@cpan.org>
  • Comment on Re^2: brian's Guide to Solving Any Perl Problem

Replies are listed 'Best First'.
Re^3: brian's Guide to Solving Any Perl Problem
by dragonchild (Archbishop) on Feb 07, 2005 at 17:06 UTC
    However, if I'm doing really big things, I usually have a debug() or trace() function lying around.

    But not a log() function. (Don't laugh, I've been bitten by this one.)

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re^3: brian's Guide to Solving Any Perl Problem
by ff (Hermit) on Jul 25, 2004 at 17:55 UTC
    Of course it's fine to save warn() for "real" error messages, but then the same could be said for only using print() for real output messages.

    My problem, for which I'd welcome suggestions, is that I'm not familiar with how to use debug() in the midst of debugging a huge Tk-based application that I'm working on. The subroutines I am debugging get fired when I click one of the Tk buttons, and I know for sure that I can get at my warn() messages as above via my STDERR files. Out of ignorance, I'm just expecting use of debug() to be impractical.

      The debug() function can be whatever you want it to be, because you have to write it.

      The print() loses against warn() because I can redefine the behaviour of warn() without changing the statements.

      --
      brian d foy <bdfoy@cpan.org>
Re^3: brian's Guide to Solving Any Perl Problem
by Bloodnok (Vicar) on Jun 04, 2014 at 10:04 UTC
    A most enlightening post, if I may say so, brian_d_foy.

    I also used to use warn() until I realised that, when re-running Test::* based modules, it [the use of warn()] 'gets in the way' of true warnings - ever since when I, like you, define an additional sub to printf STDERR ... - thus the code behaves as I think it should whilst still generating debugging messages that don't cause test case failures.

    A user level that continues to overstate my experience :-))