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.
Try this:
$^P &= ~0x100; # disable informative "file" names for evals
$^P &= ~0x200; # disable informative names for anonymous subroutines
Re:Feel cleaner with $^P...
Ovid on 2008-07-24T17:03:02
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.
Re:Feel cleaner with $^P...
Ovid on 2008-07-24T17:08:22
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).