Data::Dumper is incapable of properly dumping closures. You can use it (at least later versions) as an alternate interface to B::Deparse which can dump code, but unfortunately Deparse is only able to tell half the story, that is the source code involved in the subroutine, it is not able to provide the context required to properly recreate a closure. DD should be able to provide the context, but for many reasons it does not.

Enter Data::Dump::Streamer. DDS is specifically designed to be capable of dumping closures properly. diotalevi and I spent a fair amount of time making the closure dumping code work properly and IMO we have done a pretty reasonable job. In some situations you may find that DDS needs to rename some of the variables you used in your code, but under normal circumstances this isnt required.

If you have any trouble with using DDS for this please let me know.

Update: Fixed diotalevis name. :-)


In reply to Re: Dispatch Table and Data::Dumper (use Data::Dump::Streamer instead) by demerphq
in thread Dispatch Table and Data::Dumper by ghenry

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":