|
NAMEBencode - BitTorrent serialisation formatVERSIONversion 1.500SYNOPSISuse Bencode qw( bencode bdecode ); my $bencoded = bencode { 'age' => 25, 'eyes' => 'blue' }; print $bencoded, "\n"; my $decoded = bdecode $bencoded; DESCRIPTIONThis module implements the BitTorrent bencode serialisation format, as described in <http://www.bittorrent.org/beps/bep_0003.html#bencoding>.INTERFACE"bencode( $datastructure [, $undef_mode ] )"Takes data to be encoded as a single argument which may be a scalar, or may be a reference to either a scalar, an array or a hash. Arrays and hashes may in turn contain values of these same types. Plain scalars that look like canonically represented integers will be serialised as such. To bypass the heuristic and force serialisation as a string, use a reference to a scalar.The second argument is optional (in which case it defaults to "str") and specifies how to treat "undef" values. You can pick one of three options:
Croaks on unhandled data types. "bdecode( $string [, $do_lenient_decode [, $max_depth ] ] )"Takes a string and returns the corresponding deserialised data structure.If you pass a true value for the second option, it will disregard the sort order of dict keys. This violation of the bencode format is somewhat common. If you pass an integer for the third option, it will croak when attempting to parse dictionaries nested deeper than this level, to prevent DoS attacks using maliciously crafted input. Croaks on malformed data. DIAGNOSTICS
The format does not support this. BUGS AND LIMITATIONSStrings and numbers are practically indistinguishable in Perl, so "bencode()" has to resort to a heuristic to decide how to serialise a scalar. This cannot be fixed.AUTHORAristotle Pagaltzis <pagaltzis@gmx.de>COPYRIGHT AND LICENSEThis software is copyright (c) 2017 by Aristotle Pagaltzis.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |