[Omaha.pm] debugger - $DB::single = 1;

Jay Hannah jay at jays.net
Sun Dec 16 08:09:26 PST 2007


Oh, cool...

Catalyst just introduced me to

    $DB::single = 1;

If you throw that statement in your code then run your program under  
the debugger and hit "c" to continue, the debugger will stop on the  
next line.

Under some circumstances this might be more convenient than the way I  
normally set breakpoints: via a .perldb file:

===============
$ cat .perldb
sub afterinit {
   my $lib = "/Library/Perl/5.8.6";
   push @DB::typeahead,
     "f $lib/Control/Rates/Avail.pm", "b 189",
}
===============

While developing web apps under Catalyst $DB::single is really handy.  
You can launch your Catalyst server via the debugger, hit "c", and  
then use your browser to click around in your application just like  
normal. This way the browser keeps doing all its magical javascript /  
cookie stuff, and your server stops right after $DB::single so you  
can start debugging right there in real-time.

Since I'm still learning the Catalyst framework, this is HUGE for me,  
since I'm still feeling my way through the framework.  :)  Yes, I  
could still use .perldb to accomplish the same things, but I'm still  
fumbling through Catalyst namespaces, so $DB::single is awesomely  
lazy.  :)

j


Catalyst:
http://catalyst.perl.org/

More info on $DB::single:
http://search.cpan.org/~nwclark/perl-5.8.8/pod/ 
perldebug.pod#Debugging_compile-time_statements




More information about the Omaha-pm mailing list