Well.. Here's what I've done out of this discussion thread.
It's a little bit mischievious.. but.. it's ok for now..

Let's imagine script.pl

#!/usr/bin/perl use strict; use Getopt::Std::Strict 'dh'; INIT { $SIG{__WARN__} = $opt_d ? sub { warn(" # @_\n") } : sub { 1 }; $opt_h and print usage() and exit; } warn "Hi there. I am stuff, very interersting stuff."; sub usage { "-d flag to see interesting stuff\n" }

So essentially, I can code debug into an existing class or script, that simply turns warnings off or on via something like an option flag or a class DEBUG variable. Very sexy.

Back to your point.

Yes, I have to hand it to you .. "$DEBUG and ..." is not as clear as "... if $DEBUG". To the normal human being. I think I've been using and or ? : so much that you just start to think like the interpreter a little bit so.. it becomes part of your language at the time. I feel no difference between "x and y" and "y if x". Odd.


In reply to Re^2: using warn instead or print STDERR? by leocharre
in thread using warn instead or print STDERR? by leocharre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.