Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • $log->debug("a debug message") if $log->is_debug();

    I'm not sure why you want the "if" clause. I'd prefer to have the debug method just do nothing unless debugging is enabled. If you're trying to avoid a method call, you'd want:

    $log->debug("a debug message") if $is_debug;

    though personally I'd just prefer:

    $log->debug("a debug message");

    • You're right, that was a poorly chosen example. Yes, $log->debug() won't do anything unless debugging was enabled. Here's a more appropriate use of the conditional:

              $log->debug("current args: " . Dumper(\@_))
                    if $log->is_debug();

      The idea is to use the conditional when you don't want to compute the arguments (in this case, Dumper()) unnecessarily.