in reply to Debugging in packages
And, a simple accessor method like :sub dbg { my ($self,$msg) = @_; return if (! $self->{_debug}); print STDERR "[DEBUG] : $msg\n"; }
While this all may seem a bit elaborate, it is excedingly useful to have as a standard for every module. If the $main::DEBUG is the approach you prefer, there is always more than one way to do it, and changing dbg to the following would work :sub debug { my ($self,$val) = @_; $self->{_debug} = $val if (defined $val); $self->{_debug}; }
sub dbg { my $msg = shift; print "[DEBUG] : $msg\n" if ($main::DEBUG); }
|
---|