Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: How to turn a "developer code" into a "user code"

by duelafn (Vicar)
on Mar 11, 2012 at 19:19 UTC ( #958998=note: print w/replies, xml ) Need Help??

in reply to How to turn a "developer code" into a "user code"

I tend to prefer command-line switches (I use --DEBUG). You can then conditionally load modules as appropriate using require or eval (you could of course, build your conditional using your $I_AM_DEV, but I personally find command line switches far more elegant and less annoying than modifying code to enable/disable such things). Example:

use Getopt::Long; my %OPT; GetOptions \%OPT, qw/ help|h DEBUG / or ($OPT{help} = 1); if ($OPT{DEBUG}) { # whatever you like: require Data::Dump; eval "use Carp::Always"; } ... say "Got some data:\n", Data::Dump::pp(\%my_data) if $OPT{DEBUG};

Good Day,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://958998]
[shmem]: Discipulus of course ;-)
[LanX]: shmem I upvoted your reply ... for sympathy only
[LanX]: ;)
[Discipulus]: good night monks!
[shmem]: LanX: oh... now I have to figure out if this is good or bad news.
LanX bad day monks ?
[LanX]: hope you find sleep
[shmem]: LanX: which one?
[LanX]: the last
Discipulus yes a very bad day

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-04-29 22:41 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.