Data::Dumper and Data::Dump::Streamer can, at least for plain code references that are not closures (or, to be more precise, are not closing over lexical variables outside their scope). Of course, that doesn't help you much, since you then have either two formats, the compact format of Storable and the less compact formats of Data::Dumper or DDS. Also, if you have arbitrary, non-trivial callbacks, there is a good chance that you won't be able to properly restore them, and the differences are subtle (but I have difficulties with coming up with an example where it's not obvious why the one does work and the other doesn't, so maybe it will always work like you expect if you manage to have the right expectations). The critical point is whether you can serialize/deserialize all callbacks in one go:
{ # these two subroutines and $i must be serialized in one go # so the dumper knows that the $i++ means the same variable # in both code structures: my $i; sub increment { $i++ }; sub decrement { $i-- }; };
In reply to Re: Saving/restoring coderefs.
by Corion
in thread Saving/restoring coderefs.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |