Well... would you believe that it wasn't a very good
example? :)
That said, there are several situations where I might do something
like this:
- When my eval to require the module is wrapped in
another eval, where the outer eval is a general exception
handler of sorts. In this case, I'd perhaps have an exception
handler set up for this particular exception: loading a module
failed. So I'd die w/ that particular exception object (using
5.005's (I think) ability to die with an object). I do this
often in mod_perl apps... in fact, I probably abuse the
technique. :)
- This is kind of similar to the first example, but
oftentimes I'd rather give an explanation of why the module-load
failed, rather than just give the standard "can't find in
@INC" message. As you did above, in fact.
What I do wonder is why you're using
warn above. If code
you're writing absolutely requires a module to work, why wouldn't you
want to
die? Just wondering.