Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: how to use Data::Dumper inside a module?

by naChoZ (Curate)
on Feb 11, 2005 at 18:54 UTC ( [id://430207]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://430207]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found