There are plenty of ways in Perl for the source code of a package to not match the "in memory" version of that code. Usually this is not a problem, but when it causes bugs, it can be very frustrating to debug. Here's one time where it caused me to waste over an hour of debugging:
use Test::More 'no_plan';
# many tests
ok foo($x), '... and foo($x) should return true';
What happened was that the use_ok failed, but since I forgot to put an or die modifier after it, I didn't notice that the use statement failed. Many tests scrolled past and I couldn't figure out why my final test was failing.
This can fail when you try to do something like this:
eval "use Some::Package";
my $object = Some::Package->new;
If we forget to check whether or not the eval succeeded, Perl attempts to compile the code and gives up when it can't. This can leave you with what is effectively a partially compiled namespace and strange bugs abound (I was getting a segfault).
To find out if what's in memory matches what you think it should be, I'm writing Devel::Recreate:
use Devel::Recreate 'recreate';
Due to the dynamic nature of Perl, this is very tough to do. Also, strange bugs have been cropping up (some of which I know are fixed in 5.9). Currently, I have it listing the variables defined and the subroutines defined. Now I'm working on the use and require statements. It should probably always be considered experimental as there are too many corner cases I don't know how to work out. I haven't figured out how to capture code outside of subroutines. BEGIN, END, INIT and CHECK blocks don't seem to be coverable (they're not really subroutines), and I can't distinguish between fully qualified package variables and variables declared with our.
All things considered, I'm not sure if this code will be useful or not, but it's an interesting tour of strange bits of Perl.