salva has asked for the wisdom of the Perl Monks concerning the following question:
I need a serializer that can be instructed to replace some inner objects on the fly just before serializing then using a callback.
Storable has the STORABLE_freeze and STORABLE_thaw hooks but they are not per-object but per-class and besides that, they are methods of the class, not something that can be controlled by the code calling the serializer.
I was thinking of extending Storable, but frankly, its code its one of the worst examples of code rot I have ever seen and so, my question.
update: an example of what I need to do:
my $data = serialize $tree, sub { my $obj = shift; if (check_some_condition($obj)) { return replace($obj) } return (); # serialize $obj as is };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storable alternatives
by tobyink (Canon) on May 17, 2013 at 13:59 UTC | |
|
Re: Storable alternatives
by BrowserUk (Patriarch) on May 17, 2013 at 17:09 UTC | |
|
Re: Storable alternatives
by BillKSmith (Monsignor) on May 17, 2013 at 14:30 UTC | |
|
Re: Storable alternatives
by vsespb (Chaplain) on May 17, 2013 at 13:06 UTC | |
by salva (Canon) on May 17, 2013 at 13:41 UTC | |
by vsespb (Chaplain) on May 17, 2013 at 13:52 UTC | |
by salva (Canon) on May 17, 2013 at 13:55 UTC | |
|
Re: Storable alternatives
by locked_user sundialsvc4 (Abbot) on May 17, 2013 at 13:22 UTC | |
by salva (Canon) on May 17, 2013 at 13:52 UTC |