You can reset the code from Data :: Dumper after setting $Data::Dumper::Deparse to the true value, but this is only for debugging purposes, not serialization.
I would advise you to return to the question of why MooseX :: Storage does not work for you, since the authors tried very hard to present a well-functioning and reliable solution for serializing Moose objects.
Update: it looks like you are facing problems that serialize the _offset_sub attribute as described in this question . Since this attribute has a builder, and its construction is pretty trivial (it just looks at the current value of another attribute), you do not need to serialize it at all - when you deserialize your object and want to use it again when you call $this->offset , the builder will be called upon the first call. Therefore, you should simply mark it as "do not serialize":
use MooseX::Storage; has '_offset_sub' => ( is => 'ro', isa => 'CodeRef', traits => [ 'DoNotSerialize' ], lazy => 1, builder => '_build_offset_sub', init_arg => undef, );
Finally, this is somewhat orthogonal, but you can reset the offset and _offset_sub attributes together using the native attribute 'Code' attribute:
has offset => ( is => 'bare', isa => 'CodeRef', traits => [ qw(Code DoNotSerialize) ], lazy => 1, builder => '_build_offset', init_arg => undef, handles => { offset => 'execute_method', }, ); sub _build_offset { my ($self) = @_;
Ether source share