in reply to how to use Data::Dumper inside a module?
You might find this useful. Kanji gave me this little sample snippet that he wrote:
package My::Debug; use base Exporter; use Data::Dumper 'Dumper'; our $DEBUG_LEVEL = 0; our @EXPORT = qw( debug debug_level ); sub debug { return unless $DEBUG_LEVEL; my($pre_msg, $var, $post_msg) = @_; no warnings; print join( "\n", "", $pre_msg, "<" x 20, Dumper($var), ">" x 20, $post_msg, "" ); } sub debug_level { $DEBUG_LEVEL = shift; } 1;
Elsewhere...
use My::Debug; debug_level( $opt_v ); sub foo_sub { ... code ... debug('begin showing foovar', $foovar, 'end of foovar'); ... code ... }
--
"This alcoholism thing, I think it's just clever propaganda produced by people who want you to buy more bottled water." -- pedestrianwolf
|
|---|