in reply to Serializing code refs

I believe what you want would require some modifications to the highly experimental B::Bytecode. That module was originally intended to allow saving and later loading compiled versions of scripts or modules for efficiency. AIUI, it turned out that perl's code structure is so verbose (since it really wasn't designed with this in mind), that the costs to read in saved bytecode exceed what it takes to read and compile in the first place.

I'd encourage you to use Data::Dumper. It may not work on 100% of all code, but it's close (leaving aside issues of closures, which you would also have with bytecode), and when bugs are reported they do get fixed promptly.

Replies are listed 'Best First'.
Re^2: Serializing code refs
by Akhasha (Scribe) on Feb 25, 2005 at 06:38 UTC
    Thanks for the interesting pointer, I guess this won't be solved gracefully until the advent of Perl6. I should have mentioned that I'm using Perl 5.6.1 on Debian stable, for which I'm sure B::Bytecode is not intended :)

    Running the subroutine source through Data::Dumper is the plan for production, just my mind wouldn't let go of the idea since its quite easy in Python.
      B::Bytecode is a core module, and is included in 5.6.1.
        Thanks for pointing that out, there it is under my nose!
      Er, but why do you *want* the bytecode?
        To save the cost of re-evaluating the source when the routine is loaded.