HDB::Encode - Hybrid DataBase - HASH/ARRAY enconding.
You can save HASH and ARRAY structures inside columns of a table in the database.
** The column that will receive the encoded data need to have a good size for the encoded HASH/ARRAY!
my %HASH = ( 'a' => 1 , 'b' => 2 , 'c' => 3 , 'd' => { 'da' => 41 , 'db' => 42 } , 'e' => [qw(x y z)] , ) ; $HDB->insert( 'users' , { user => 'joe' , name => 'joe tribianny' , more => \%HASH , } ) ; ... $HDB->insert( 'users' , { user => 'joe' , name => 'joe tribianny' , more => { a => 1 , b => 2 } , } ) ; ... my %hash = $HDB->select( 'users' , 'user == joe' , col => 'more' , '$$@' ) ; # $$@ to return directly the HASH.
** You don't need to use this methods, HDB will make everything automatically.
Encode a HASH/ARRAY. Will use Pack_HASH & Pack_ARRAY.
Encode a HASH.
Encode an ARRAY.
Decode a HASH/ARRAY. Will use UnPack_HASH & UnPack_ARRAY.
Decode a HASH.
Decode an ARRAY.
Check if the encoded data is a HASH.
Check if the encoded data is an ARRAY.
Check if the encoded data is ok.
Return the size of the HASH/ARRAY encoded. This will calculate the size without generate the encoded data.
Will use Packed_SIZE_HASH & Packed_SIZE_ARRAY.
Return the size of the HASH encoded without generate it.
Return the size of the ARRAY encoded without generate it.
The encoded HASH/ARRAY are very similar:
%HDB_PACKED_HASH%[1.0]{50}:DATA 1.0 >> Format version. 50 >> DATA size. DATA >> The encoded data. # For ARRAY is: %HDB_PACKED_ARRAY%... ** The data has this begin to identify the encoded data in the database. ** The size is used to check if the data is crashed. DATA for HASH: 02:aa4:bbbb 0 >> normal value. 1 for HASH in the value. 2 for ARRAY in the value. 2 >> size of key. aa >> key 4 >> size of value. bbbb >> value DATA for ARRAY: 02:aa 0 >> normal value. 1 for HASH in the value. 2 for ARRAY in the value. 2 >> size of value. aa >> value
HDB, HDB::CMDS, HDB::sqlite, HDB::mysql.
Graciliano M. P. <gm@virtuasites.com.br>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HDB, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HDB
CPAN shell
perl -MCPAN -e shell install HDB
For more information on module installation, please visit the detailed CPAN module installation guide.