Parse::Copec64 - ``Cortext Perl Code 64'' serialization format
use Parse::Copec64;
$my_data = [ [ [ 1, 2, {} ], { 0=>"a+b", 2=>"abc" }, [], { 1=>2 } ], 0 ];
$encoded = perl_to_copec64($my_data);
$decoded = copec64_to_perl($encoded);
# $encoded contains solid string "A2A4A312hH20_3XjYO2r3abcaH1120" # $decoded is a copy (clone) of $my_data
use Data::NeatDump; print dump($my_data, $encoded, $decoded);
Transfering perl data from one environment to another may require encoding perl structure to string and then decoding this string to the source perl structure.
This module introduces string format, suitable for any imaginable transfer, named ``Cortext Perl Code 64''.
This module can be used for cloning perl structures by encoding with the following decoding.
The utf8-flag of a scalar data (if any) is preserved; without a utf8-flag the scalar data is considered to be binary.
The character set of encoded string contains 64 characters: * digits = 10 characters * english letters 26+26 = 52 characters * underscore and minus signs = 2 characters
So, every encoded character has 6-bit information entropy.
Currently supported only normal perl structures, recursively including SCALAR, ARRAY, HASH references and scalars. No loops (self references) allowed.
The functions suppose the characters in perl scalars have 8-bit length (256 characters in charset).
Currently encoded string is one very long line. One can think to insert new-line every 64 characters to get shorter lines.
Note, if several perl structures are passed, the encoded string will contain all of them chained (one after another).
Options:
* compress - boolean, compress the output unconditionally * compress_if_helps - boolean, compress the output if reduced * compress_or_crypt - boolean, compress the output if reduced or crypt * crypt - boolean, slightly crypt the output * break - integer, the number of chars in line to break * indent - whitespace string, to use as line indentation
Note, if several perl structures are passed, the encoded string will contain all of them chained (one after another).
Note, if given string includes several perl structures (one after another), they all will be returned, when called in list context.