Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday July 24, 2008
05:27 AM

Buggered by the Debugger

[ #37006 ]

Seems the debugger subtly alters the behavior of caller, so relying on its values is problematic. I have the following embarrassing code as a result:

# XXX Yuck.  The debugger has buggered me.  It alters the behavior of
# caller.
my $is_top_predicate = $DB::I_m_init
    ? $calling_sub !~ /^$anon_sub/
    : $calling_sub ne $anon_sub;

This is because if the conditional true, $calling_sub is usually t::__ANON__. Under the debugger it's more like t::__ANON__[t/ast.t:47]

I feel dirty now.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Try this:
    $^P &= ~0x100; # disable informative "file" names for evals
    $^P &= ~0x200; # disable informative names for anonymous subroutines

    • Thank you! That's much nicer. Where in the docs can I look that up? I only knew about $DB::i_m_init by doing x \%DB:: while in the debugger.

    • Ah, never mind. I see it now with perldoc -A '$^P' (you need the new Pod::Perldoc for that switch, though I see the latest version has switched that to -v).