Data-Transform-ExplicitMetadata

 view release on metacpan or  search on metacpan

lib/Data/Transform/ExplicitMetadata.pm  view on Meta::CPAN

hashref with the keys NAME, PACKAGE, SCALAR, ARRAY, HASH, IO and CODE.  For
compiled regexps, __value will be a 2-element arrayref of the pattern and
modifiers.  For coderefs, __value will be the stringified reference, like
"CODE=(0x12345678)".  For v-strings and v-string refs, __value will by an
arrayref containing the integers making up the v-string.

For tied objects, C<__tied> will be contain the original value hidden by tie()
and __value will contain the tied data.  The original data is retrieved by:

=over 4

=item *

call tied() to get a copy of the tied data

=item *

localize the UNTIE method in the appropriate class

=item *

untie the variable

=item *

save a copy of the original value

=item *

localize the appropriate TIE* mythod to return the tied data

=item *

call tie() to retie the variable

=back

if C<__recursive> is true, then __value will contain a string representation
of the first place this reference was seen in the data structure.

encode() handles arbitrarily nested data structures, meaning that
values in the __values slot may also be encoded this way.

=item decode

Accepts a single value and returns a copy of the data structure originally
passed to encode().  __refaddr information is discarded and new copies of
nested data structures is created.  Self-referential data is re-linked to the
appropriate placxe in the new copy.  Blessed references are re-bless into
the original packages.

Tied variables are re-tied by localizing the appropriate TIE* method to return
the tied data.  The variable's original data is filled in before calling tie().

The IO slot of typeglobs is recreated by opening the handle with the same
descriptor number and open mode.  It will first try fcntl() with F_GETFL
to determine the open mode, falling back to using FileHandle::Fmode if it's
available.  Finally, it will first try re-opening the file descriptor in
read mode, then write mode.

Coderefs cannot be decoded properly.  They are recreated by returning a
reference to a dummy sub that returns a message explaning the situation.

=back

=head1 SEE ALSO

L<JSON>, L<Sereal>, L<Data::Dumper>, L<FileHandle::Fmode>

=head1 AUTHOR

Anthony Brummett <brummett@cpan.org>

=head1 COPYRIGHT

Copyright 2016, Anthony Brummett.  This module is free software. It may
be used, redistributed and/or modified under the same terms as Perl itself.



( run in 2.758 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )