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


in reply to using warn instead or print STDERR?

Thanks for asking such an interesting question. I learned from the responses.

This is barely not offtopic, or something. I'd like to make a suggestion and ask a question.

IMO, these kind of debugging output lines are a perfect place to use the dreaded postfix if. I find:

warn "Watch out, there a llamas!\n" if $DEBUG;
to be clearer than:
$DEBUG and warn "Watch out, there a llamas!\n";

I guess its becuase the short circuit in the 'and' is not part of the meaning of the English word. The use or for things like open(...) or die "Ugh." doesn't bother me, because the sense is the same in English as in Perl.

Is there a particular reason you like to use the $DEBUG and ... form?


TGI says moo