forked from demerphq/Data-Undump
/
Undump.pm
87 lines (56 loc) · 1.91 KB
/
Undump.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package Data::Undump;
use 5.008008;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw( undump );
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
our @EXPORT = qw(undump);
our $VERSION = '0.01';
require XSLoader;
XSLoader::load('Data::Undump', $VERSION);
1;
__END__
=head1 NAME
Data::Undump - Perl extension for securely and quickly deserializing simple Data::Dumper dumps
=head1 SYNOPSIS
use Data::Undump qw(undump);
my $dump= Data::Dumper->new([$simple_thing])->Terse(1)->Dump();
undump($dump);
=head1 DESCRIPTION
Securely and quickly deserialize simple Data::Dumper dumps.
=head2 EXPORT
By default exports the undump subroutine.
=head1 FUNCTIONS
=head2 undump
Undumps a Data::Dumper style data structure.
Takes a plain string (magic not currently respected)
containing a Data::Dumper Terse/Deepcopy style C<Dumper> output
(ie. no C<$VAR1 => at the front allowed currently) and returns
either undef for a failed parse, or a scalar value of the
value parsed.
Restricted to objects nested up to 100 items deep.
=head1 POTENTIAL ENHANCEMENTS
Support for the following isn't implemented but might be in
future enhancements.
* String magic on input scalar
* qr//
* ref to object. Eg \['foo']
* Make it possible to parse a list instead of a scalar.
* Blessed objects?
* Cyclic structures?
* Less/more tolerant parsing rules?
* Filters? (Block things by their position in the structure?)
* Conversion? (IE, we have '[1,1,1]' in the input, and we know we wont
* need it so parse it as '1,1,1' instead.
=head1 SEE ALSO
L<Data::Dumper> L<eval>
=head1 AUTHOR
Yves Orton, E<lt>demerphq@gmail.comE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012 by Yves Orton
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
=cut