more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I shot myself in the foot (but only slightly) the other day and thought I'd share with you all.
I was testing a piece of code something like: but many of the classes and subs called were not available. So I thought: no problem, I'll wrap a test framework around the code that provides a sub quux to return sample data and a sub AUTOLOAD to make sure things that need to return true. Since some of the things that need to return true are constructors, I'll make it sub AUTOLOAD { bless {} }. And I got it running; the real subs that existed got called; the sub quux that provided fake data got called; everything else was effectively a noop. But there was a problem with the output, and I needed to run it in the debugger, and ran into a mystery that stumped me for a little while. You can try it yourself; run perl -d -we'sub AUTOLOAD { bless {} } foo()' and note that "s" stepping into foo seems ineffective; you can do it over and over again without terminating. And using "n" gets you a "100 levels deep in subroutine calls!" warning. In retrospect, the problem was simply solved by an additional sub declaration: <Reveal this spoiler or all in this thread> In reply to AUTOLOAD mystery by ysth
|
|