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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Hmmm... (Score:1)
For most cases, a module similar to Apache::Reload is right. Put in a check for which modules have changed on disk since you loaded them, then reload them.
That doesn't help you in the case you have. But it is easy to create a module that redefines use and require. If you try to use or require another module after that, and the use or require exits with an exception, then before rethrowing the exception you replace all functions in that package with functions that will throw an exception explaining that use failed. If you want to be clever, you can also look through the exports (assuming use of Exporter) and replace exported functions and variables with similarly unusable stubs. In the situation that you describe, the failed use will then be impossible to ignore.
Or you could just take that use out of its eval. What is the eval buying you? Done right, a clearer error message upon failure. But a fatal error there is still pretty easy to debug. So just let the natural exception speak for itself!
Reply to This
Re: (Score:2)
The above example is only one of many. If a module is not behaving the way I expect it to, particularly if "deep magic" is involved, than it's quite reasonable for me to want to see what's actually loaded in memory instead of what I think was loaded. Just a few areas where this would be helpful:
Re: (Score:1)
Carry on. :-)
Re: (Score:2)
Yes, I'm convinced that my module could only be used as a rough debugging guide. There are too many limitations that I cannot figure out how to get around, so it should probably only be a tool that developers can use if they read the docs carefully and really understand what its limitations are.
Re: (Score:1)
Actually I don’t think it is a bad idea at all. You are right that this is not applicable in all cases in Perl because Perl was not designed to facilitate such usage. However, think Smalltalk, where a lot of “magic” is no problem because what you are browsing is the live in-memory representation of the program and so you see what it looks like after the meta-program parts have taken place.
This is just the same thing for Perl. Of course it’s not going to work nearly as well in Perl