view release on metacpan or search on metacpan
ext/zstd/CHANGELOG view on Meta::CPAN
lib : changed : reduced usage of stack memory
lib : fixed : several corner case bugs, by Nick Terrell
cli : new : gzstd, experimental version able to decode .gz files, by Przemyslaw Skibinski
cli : new : preserve file attributes
cli : new : added zstdless and zstdgrep tools
cli : fixed : status displays total amount decoded, even for file consisting of multiple frames (like pzstd)
cli : fixed : zstdcat
zlib_wrapper : added support for gz* functions, by Przemyslaw Skibinski
install : better compatibility with FreeBSD, by Dimitry Andric
source tree : changed : zbuff source files moved to lib/deprecated
view all matches for this distribution
view release on metacpan or search on metacpan
examples/bzip2_decompressor.pl view on Meta::CPAN
my @zrle;
my $code = '';
my $sel_idx = 0;
my $tree = $huffman_trees[$sels->[$sel_idx]];
my $decoded = 50;
while (!eof($fh)) {
$code .= read_bit($fh, \$buffer);
if (length($code) > $MaxHuffmanBits) {
examples/bzip2_decompressor.pl view on Meta::CPAN
}
push @zrle, $sym;
$code = '';
if (--$decoded <= 0) {
if (++$sel_idx <= $#$sels) {
$tree = $huffman_trees[$sels->[$sel_idx]];
}
else {
die "No more selectors"; # should not happen
}
$decoded = 50;
}
}
}
##say STDERR "ZRLE: (@zrle)";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Conclave/OTK/Backend/4store.pm view on Meta::CPAN
unless ($response->is_success) {
print STDERR "Query failed: ", $response->status_line, "\n";
}
else {
my $tsv = $response->decoded_content;
# FIXME
my @lines = split /\n/, $tsv;
shift @lines;
foreach my $triple (@lines) {
$triple =~ s/[<>]//g;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Concurrent/Data/Serializer.pm view on Meta::CPAN
sub deserialize {
my ($self, $string) = @_;
$string =~ s/\0/\n/mg;
my $decoded = decode_base64 ($string);
return $$self{Method} eq "Dumper" ? eval $decoded : thaw( $decoded );
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Conductrics/Agent.pm view on Meta::CPAN
}
my $response = $ua->get($uri);
if ($response->is_success) {
if ($response->code != 200) {
warn "Content: ", $response->decoded_content; # or whatever
warn "Code: ", $response->code;
warn "Err:", $response->message;
warn "Something get wrong on response";
warn Dumper($response);
}
JSON::MaybeXS::decode_json($response->decoded_content);
} else {
warn "Content: ", $response->decoded_content; # or whatever
warn "Code: ", $response->code;
warn "Err:", $response->message;
die $response->status_line;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Conductrics/Client.pm view on Meta::CPAN
$request->header(Content_Type => 'application/json');
#use Data::Dumper;
#print Dumper($request);
my $response = $ua->request($request);
if ($response->is_success) {
return JSON::MaybeXS::decode_json($response->decoded_content);
} else {
warn "Content: ", $response->decoded_content; # or whatever
warn "Code: ", $response->code;
warn "Err:", $response->message;
die $response->status_line;
}
}
lib/Conductrics/Client.pm view on Meta::CPAN
}
my $request = HTTP::Request->new("DELETE", $uri);
my $response = $ua->request($request);
if ($response->is_success) {
return JSON::MaybeXS::decode_json($response->decoded_content);
} else {
warn "Content: ", $response->decoded_content; # or whatever
warn "Code: ", $response->code;
warn "Err:", $response->message;
die $response->status_line;
}
}
lib/Conductrics/Client.pm view on Meta::CPAN
unless (defined $url) {
$url = 'http://api.conductrics.com/' . $self->ownerCode . '/schema/agent';
}
my $response = $ua->get($url);
if ($response->is_success) {
return $response->decoded_content;
}
warn "Content: ", $response->decoded_content; # or whatever
warn "Code: ", $response->code;
warn "Err:", $response->message;
die $response->status_line;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/App.pm view on Meta::CPAN
);
my $res = $ua->get( $input->{include} );
if ( $res->is_success ) {
return $res->decoded_content;
}
else {
croak 'Failed to get '
. join( ' -> ', map { "\"$_\"" } @{ $input->{sources} } )
. '; '
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/IOD/Base.pm view on Meta::CPAN
}
\@argv;
}
# return ($err, $res, $decoded_val)
sub _parse_raw_value {
my ($self, $val, $needs_res) = @_;
if ($val =~ /\A!/ && $self->{enable_encoding}) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/IOD/Document.pm view on Meta::CPAN
$_merge->() if defined($merge) && $num_seen_section_lines > 1;
$cur_section = $line->[COL_S_SECTION];
$parser->{_cur_section} = $cur_section if $parser->{enable_expr}; #TMP HACK
$res->{$cur_section} //= {};
} elsif ($type eq 'K') {
# the common case is that value are not decoded or
# quoted/bracketed/braced, so we avoid calling _parse_raw_value here
# to avoid overhead
my $key = $line->[COL_K_KEY];
my $val = $line->[COL_K_VALUE_RAW];
if ($val =~ /\A["!\\[\{]/) {
my ($err, $parse_res, $decoded_val) =
$parser->_parse_raw_value($val);
die "IOD document:$linum: Invalid value: $err" if $err;
$val = $decoded_val;
} else {
$val =~ s/\s*[#;].*//; # strip comment
}
if (exists $res->{$cur_section}{$key}) {
lib/Config/IOD/Document.pm view on Meta::CPAN
=item * cond => code
Will only delete key if C<cond> returns true. C<cond> will be called with C<<
($self, %args) >> where the hash will contain these keys: C<linum> (int, line
number), C<parsed> (array, parsed line), C<key> (string, key name), C<value>
(NOT YET IMPLEMENTED), C<raw_value> (str, raw/undecoded value).
=back
=head2 $doc->delete_section([\%opts, ]$section) => $num_deleted
lib/Config/IOD/Document.pm view on Meta::CPAN
=back
=head2 $doc->dump([ \%opts ]) => hoh
Return a hoh (hash of section names and hashes, where each of the second-level
hash is of keys and values), Values will be decoded and merging will be done,
but includes are not processed (even though C<include> directive is active).
Options:
=over
lib/Config/IOD/Document.pm view on Meta::CPAN
Execute C<$code> for each key found in document, in order of occurrence.
C<$code> will be called with arguments C<< ($self, %args) >> where C<%args> will
contain these keys: C<section> (str, current section name), C<key> (str, key
name), C<value> (any, value, NOT YET IMPLEMENTED/AVAILABLE), C<raw_value> (str,
raw/undecoded value), C<linum> (int, line number, 1-based), C<parsed> (array,
parsed line).
Options:
=over
lib/Config/IOD/Document.pm view on Meta::CPAN
If found, will return an arrayref containing directive name and arguments.
Otherwise, will return undef.
=head2 $doc->get_value($section, $key) => $value
Get value. Values are decoded and section merging is respected, but includes are
not processed.
Internally, will do a C<dump()> and cache the result so subsequent
C<get_value()> will avoid re-parsing the whole document. (The cache will
automatically be discarded is one of document-modifying methods like
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/Model/models/Systemd/Common/Exec.pl view on Meta::CPAN
Interface|https://systemd.io/CONTAINER_INTERFACE> documentation for details
about the former. For the latter, pass L<DMI/SMBIOS|https://www.dmtf.org/standards/smbios> OEM string table entries
(field type
11) with a prefix of C<io.systemd.credential:> or
C<io.systemd.credential.binary:>. In both cases a key/value pair separated by
C<=> is expected, in the latter case the right-hand side is Base64 decoded when
parsed (thus permitting binary data to be passed in). Example
L<qemu|https://www.qemu.org/docs/master/system/index.html> switch: C<-smbios
type=11,value=io.systemd.credential:xx=yy>, or C<-smbios
type=11,value=io.systemd.credential.binary:rick=TmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXA=>. Alternatively,
use the qemu C<fw_cfg> node
lib/Config/Model/models/Systemd/Common/Exec.pl view on Meta::CPAN
Interface|https://systemd.io/CONTAINER_INTERFACE> documentation for details
about the former. For the latter, pass L<DMI/SMBIOS|https://www.dmtf.org/standards/smbios> OEM string table entries
(field type
11) with a prefix of C<io.systemd.credential:> or
C<io.systemd.credential.binary:>. In both cases a key/value pair separated by
C<=> is expected, in the latter case the right-hand side is Base64 decoded when
parsed (thus permitting binary data to be passed in). Example
L<qemu|https://www.qemu.org/docs/master/system/index.html> switch: C<-smbios
type=11,value=io.systemd.credential:xx=yy>, or C<-smbios
type=11,value=io.systemd.credential.binary:rick=TmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXA=>. Alternatively,
use the qemu C<fw_cfg> node
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/Patch.pm view on Meta::CPAN
###########################################
my($self, $string) = @_;
# Decode a hidden string
$string =~ s/^$self->{comment_char} //gm;
my $decoded = decode_base64($string);
return $decoded;
}
###########################################
sub replstring_extract {
###########################################
view all matches for this distribution
view release on metacpan or search on metacpan
Any code which imports My::Library::Config will use the same API
exported by Config::Tree to access the %volatile, @stack and %default
in My::Library::Config.
Config::Tree subclasses may wish to override _find to modify how the
variables are scanned and how the key is decoded.
A library should normally provide any default values which are
necessary and leave loading & saving to the application using it.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Connector/Proxy/HTTP.pm view on Meta::CPAN
my $response = $self->agent()->request($req);
# error handling
if (!$response->is_success) {
$self->log()->error($response->status_line);
$self->log()->error($response->decoded_content);
die "Unable to upload data to server";
}
$self->log()->debug("Set responded with: " . $response->status_line);
$self->log()->trace($response->decoded_content) if ($self->log()->is_trace());
return 1;
}
sub get_meta {
lib/Connector/Proxy/HTTP.pm view on Meta::CPAN
sub _parse_result {
my $self = shift;
my $response = shift;
my $res = $response->decoded_content;
chomp $res if ($self->chomp_result());
return $res;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Consul/Simple.pm view on Meta::CPAN
foreach my $entry (@entries) {
#The returned entry Value is always base64 encoded
$entry->{Value} = MIME::Base64::decode_base64($entry->{Value});
#the idea below is to try to JSON decode it. If that works,
#return the JSON decoded value. Otherwise, return it un-decoded
my $value;
eval {
$value = JSON::decode_json($entry->{Value});
};
$value = $entry->{Value} unless $value;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Contenticious/Content/Node/Directory.pm view on Meta::CPAN
# does a 'meta' file exist?
my $meta_fn = $self->filename . '/meta';
if (-f -r $meta_fn) {
# open file for decoded reading
open my $meta_fh, '<:encoding(UTF-8)', $meta_fn
or croak "couldn't open $meta_fn: $!";
# slurp
my $meta_fc = do { local $/; <$meta_fh> };
view all matches for this distribution
view release on metacpan or search on metacpan
This command handles the upload response to an "Interface Poll Signal"
message (0x5a) B<read> from the CM11. The module sends "ready" (0xc3) and
receives up to 10 bytes. The first two bytes are size and description of
the remaining bytes. These are used to decode the data bytes, but are not
returned by the B<receive_buffer> function. Each of the data bytes is
decoded as if it was a B<send> command from an external CM11 or equivalent
external source (such as an RF keypad).
$data = &ControlX10::CM11::receive_buffer($serial_port);
# $data eq "A2AK" after an external device turned off A2
print "House B Inputs 1,3,5,7,9 Brightened to 85%\n";
}
The conversion between text_data and percent makes more sense to the code
than to humans. The following table gives representative values. Others
may be received from a CM11 and will be properly decoded.
Percent Text Percent Text
0 M7 50 AA
5 ED 55 I6
10 EC 60 NF
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/ASCII/Armour.pm view on Meta::CPAN
NzuZ
=MxpZvjkrv5XyhkVCuXmsBQ==
-----END COMPRESSED FOO RECORD-----
my $decoded = $converter->unarmour( $message )
|| die $converter->errstr();
=head1 DESCRIPTION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/ASN1/asn1c.pm view on Meta::CPAN
=head2 $values = decode('pduname', $pdu);
The decode function takes the name of a template (the directory where to find
those templates can be modified with set_templatedir($dir)) and a binary pdu.
It will match the variables in the template against the decoded binary pdu and
return a reference to a hash which contains these values.
For each variable $myvalue the hash will contain four keys:
=head3 $values->{'myvalue'}
The decoded value if we could "guess" myvalues type because it was
specified as i.e. INTEGER or BIT STRING in the asn1 pdu.
=head3 $values->{'myvalue_orig'}
The original value as it was found in the unber -p output. Note that these
lib/Convert/ASN1/asn1c.pm view on Meta::CPAN
# we will parse the packet description
# to find out which "nodes" in the tag tree are interesting for us
# and we will construct a list of those interesting nodes (and how to "reach" them,
# i.e. which parent nodes they are located under. In the second step we will
# iterate over the decoded ASN data, if we are in an inetersting leaf we will decode it's value.
foreach (@lines) {
if (m/<C .*?T=\"(.*?)\"/) { push @stack, $1; }
if (m/<\/C /) { pop @stack; }
if (m/<P .*?T=\"(.*?)\"/) { push @stack, $1; }
lib/Convert/ASN1/asn1c.pm view on Meta::CPAN
# we will parse the packet description
# to find out which "nodes" in the tag tree are interesting for us
# and we will construct a list of those interesting nodes (and how to "reach" them,
# i.e. which parent nodes they are located under. In the second step we will
# iterate over the decoded ASN data, if we are in an inetersting leaf we will decode it's value.
foreach (@lines) {
if (m/<C .*?T=\"(.*?)\"/) { push @stack, $1; }
if (m/<\/C /) { pop @stack; }
if (m/<P .*?T=\"(.*?)\"/) { push @stack, $1; }
view all matches for this distribution
view release on metacpan or search on metacpan
examples/tsa3161 view on Meta::CPAN
open TSAKEY, "<$filename" or &dieif(1,"cannot open TSAKeyFile '$filename'");
binmode TSAKEY;
my $tsa_key_pem;
read TSAKEY, $tsa_key_pem, $size;
close TSAKEY;
$tsa_key = Crypt::OpenSSL::RSA->new_private_key($tsa_key_pem) or &dieif(1,"TSAKeyFile '$filename' cannot be decoded");
}
# some magic
my $time = Time::HiRes::gettimeofday() ;
my $now = int($time);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Ascii85.pm view on Meta::CPAN
=head1 SYNOPSIS
use Convert::Ascii85;
my $encoded = Convert::Ascii85::encode($data);
my $decoded = Convert::Ascii85::decode($encoded);
use Convert::Ascii85 qw(ascii85_encode ascii85_decode);
my $encoded = ascii85_encode($data);
my $decoded = ascii85_decode($encoded);
=head1 DESCRIPTION
This module implements the I<Ascii85> (also known as I<Base85>) algorithm for
encoding binary data as text. This is done by interpreting each group of four
view all matches for this distribution
view release on metacpan or search on metacpan
no subvalues, kind of like a non-reference perl scalar. If it is C<1>,
then the value is "constructed" which just means it contains a list of
subvalues which this module will en-/decode as BER tuples themselves.
The I<DATA> value is either a reference to an array of further tuples
(if the value is I<FLAGS>), some decoded representation of the value, if
this module knows how to decode it (e.g. for the integer types above) or
a binary string with the raw octets if this module doesn't know how to
interpret the namespace/tag.
Thus, you can always decode a BER data structure and at worst you get a
string in place of some nice decoded value.
See the SYNOPSIS for an example of such an encoded tuple representation.
=head2 DECODING AND ENCODING
$tuple = ber_encode $data, $Convert::BER::XS::SNMP_PROFILE;
=item ($tuple, $bytes) = ber_decode_prefix $bindata[, $profile]
Works like C<ber_decode>, except it doesn't croak when there is data after
the BER data, but instead returns the decoded value and the number of
bytes it decoded.
This is useful when you have BER data at the start of a buffer and other
data after, and you need to find the length.
Also, since BER is self-delimited, this can be used to decode multiple BER
_ber_dump $_[0], $_[1] || $DEFAULT_PROFILE, $_[2];
}
=head1 PROFILES
While any BER data can be correctly encoded and decoded out of the box, it
can be inconvenient to have to manually decode some values into a "better"
format: for instance, SNMP TimeTicks values are decoded into the raw octet
strings of their BER representation, which is quite hard to decode. With
profiles, you can change which class/tag combinations map to which decoder
function inside C<ber_decode> (and of course also which encoder functions
are used in C<ber_encode>).
This works by mapping specific class/tag combinations to an internal "ber
type".
The default profile supports the standard ASN.1 types, but no
application-specific ones. This means that class/tag combinations not in
the base set of ASN.1 are decoded into their raw octet strings.
C<Convert::BER::XS> defines two profile variables you can use out of the box:
=over
=head2 BER Types
This lists the predefined BER types. BER types are formatters used
internally to format and encode BER values. You can assign any C<BER_TYPE>
to any C<CLASS>/C<TAG> combination tgo change how that tag is decoded or
encoded.
=over
=item C<BER_TYPE_BYTES>
OBJECT IDENTIFIEERs cannot have unlimited length, although the limit is
much larger than e.g. the one imposed by SNMP or other protocols, and is
about 4kB.
Constructed strings are decoded just fine, but there should be a way to
join them for convenience.
REAL values will always be encoded in decimal form and ssometimes is
forced into a perl "NV" type, potentially losing precision.
view all matches for this distribution
view release on metacpan or search on metacpan
An I<opList> is a list of I<operator>-I<value> pairs. An operator can
be any of those defined below, or any defined by sub-classing
C<Convert::BER>, which will probably be derived from the primitives
given here.
The I<value>s depend on whether BER is being encoded or decoded:
=over 4
=item Encoding
BOOLEAN => 1,
) or die;
=item Decoding
The decoded I<value>s will be either 1 or 0.
# Decode a boolean value into $bval
$ber->decode(
BOOLEAN => \$bval,
) or die;
INTEGER => -123456,
) or die;
=item Decoding
The I<value> will be the decoded integer value.
$ber->decode(
INTEGER => \$ival,
) or die;
BIT_STRING8 => pack('B8', '10110101'),
) or die;
=item Decoding
The I<value> will be the decoded packed bits.
$ber->decode(
BIT_STRING8 => \$bval,
) or die;
REAL => 3.14159265358979,
) or die;
=item Decoding
The I<value> will be the decoded floating-point value.
$ber->decode(
REAL => \$rval,
);
values in different types, like a C structure.
=head2 SEQUENCE
A SEQUENCE is a complex type that contains other types, a bit like a C
structure. Elements inside a SEQUENCE are encoded and decoded in the
order given.
=over 4
=item Encoding
=item Decoding
I<value> should be a reference to a scalar, which will contain a
C<Convert::BER> object. This object will contain the remainder of the
current sequence or set being decoded.
# After this, ber2 will contain the encoded INTEGER B<and> STRING.
# sval will be ignored and left undefined, but bval will be decoded. The
# decode of ber2 will return the integer and string values.
$ber->decode(
SEQUENCE => [
BER => \$ber2,
STRING => \$sval,
=back
=head2 ANY
This is like the C<BER> operator except that when decoding only the
next item is decoded and placed into the C<Convert::BER> object
returned. There is no difference when encoding.
=over 4
=item Decoding
I<value> should be a reference to a scalar, which will contain a
C<Convert::BER> object. This object will only contain the next single
item in the current sequence being decoded.
# After this, ber2 will decode further, and ival and sval
# will be decoded.
$ber->decode(
INTEGER = \$ival,
ANY => \$ber2,
STRING => \$sval,
);
]
);
=item Decoding
The contents of I<value> are decoded if possible, if not then decode
continues at the next I<operator>-I<value> pair.
$ber->decode(
SEQUENCE => [
INTEGER => \$ival1,
=back
=head2 CHOICE
The I<opList> is a list of alternate I<operator>-I<value> pairs. Only
one will be encoded, and only one will be decoded.
=over 4
=item Encoding
) or die;
=item Decoding
A reference to a scalar at the start of the I<opList> is used to store
which alternative is decoded (0 for the first one, 1 for the second
one, etc.) Pass undef instead of the ref if you don't care about this,
or you store all the alternate values in different variables.
# Decode the above.
# Afterwards, $alt will be set to 2, $str will be set to 'BMP/Unicode'.
=head2 DEFINING NEW PACKING OPERATORS
As well as defining new operators which inherit from existing
operators it is also possible to define a new operator and how data is
encoded and decoded. The interface for doing this is still changing
but will be documented here when it is done. To be continued ...
=head1 LIMITATIONS
Convert::BER cannot support tags that contain more bits than can be
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Base32.pm view on Meta::CPAN
=head1 SYNOPSIS
use Convert::Base32;
$encoded = encode_base32("\x3a\x27\x0f\x93");
$decoded = decode_base32($encoded);
=head1 DESCRIPTION
This module provides functions to convert string from / to Base32
lib/Convert/Base32.pm view on Meta::CPAN
takes a string of bytes to encode and returns the encoded base32 string.
=item decode_base32($str)
Decode a base32 string by calling the decode_base32() function. This
function takes a string to decode and returns the decoded string.
This function might throw the exceptions such as "Data contains
non-base32 characters", "Length of data invalid" and "Padding
bits at the end of output buffer are not all zero".
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Base64.pm view on Meta::CPAN
=head1 SYNOPSIS
use Convert::Base64;
$encoded = encode_base64("\x3a\x27\x0f\x93");
$decoded = decode_base64($encoded);
=head1 DESCRIPTION
This module provides functions to convert strings to/from the Base64 encoding
lib/Convert/Base64.pm view on Meta::CPAN
=item *
C<decode_base64>
my $decoded = encode_base64("Zm9v");
Decode a Base64 string into a string of bytes.
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Base81.pm view on Meta::CPAN
=head1 SYNOPSIS
use Convert::Base81;
my $encoded = Convert::Base81::encode($data);
my $decoded = Convert::Base81::decode($encoded);
or
use Convert::Base81 qw(base81_encode base81_decode);
my $encoded = base81_encode($data);
my $decoded = base81_decode($encoded);
=head1 DESCRIPTION
This module implements a I<Base81> conversion for encoding binary
data as text. This is done by interpreting each group of fifteen bytes
lib/Convert/Base81.pm view on Meta::CPAN
other whitespace are stripped from the string before decoding.
This function may be exported as C<base81_decode> into the caller's namespace.
If your original data wasn't an even multiple of fifteen in length, the
decoded data will have some padding with null bytes ('\0'), which can be removed.
#
# Decode the string and compare its length with the length of the original data.
#
my $decoded = base81_decode($data);
my $padding = length($decoded) - $datalen;
chop $decoded while ($padding-- > 0);
=cut
sub decode
{
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Base85.pm view on Meta::CPAN
=head1 SYNOPSIS
use Convert::Base85;
my $encoded = Convert::Base85::encode($data);
my $decoded = Convert::Base85::decode($encoded);
or
use Convert::Base85 qw(base85_encode base85_decode);
my $encoded = base85_encode($data);
my $decoded = base85_decode($encoded);
=head1 DESCRIPTION
This module implements a I<Base85> conversion for encoding binary
data as text. This is done by interpreting each group of sixteen bytes
lib/Convert/Base85.pm view on Meta::CPAN
other whitespace are stripped from the string before decoding.
This function may be exported as C<base85_decode> into the caller's namespace.
If your original data wasn't an even multiple of sixteen in length, the
decoded data may have some padding with null bytes ('\0'), which can be removed.
#
# Decode the string and compare its length with the length of the original data.
#
my $decoded = base85_decode($data);
my $padding = length($decoded) - $datalen;
chop $decoded while ($padding-- > 0);
=cut
sub decode
{
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Base91.pm view on Meta::CPAN
use Convert::Base91 qw/encode_base91 decode_base91/;
# procedural interface
my $encoded = encode_base91 'some data';
say $encoded; # qrLg,W;Hr%w
my $decoded = decode_base91 $encoded;
say $decoded; # some data
# OO interface
my $base91 = Convert::Base91->new;
$base91->encode('some ');
lib/Convert/Base91.pm view on Meta::CPAN
Takes a string containing arbitrary bytes and returns the
base91 encoded data.
=item B<decode_base91> $base91_data
Takes a string containing base91 encoded data and returns the decoded
string of arbitrary bytes. Any non-printable character in the input is
silently ignored.
=item Convert::Base91->B<new>
lib/Convert/Base91.pm view on Meta::CPAN
Returns the base91 encoded data, and clears the state of the $base91
object so it may be used again (for either encoding or decoding).
=item $base91->B<decode>($data)
Submit the next chunk of base91 data to be decoded. Returns nothing.
Any non-printable character in the input is silently ignored.
=item $base91->B<decode_end>
Signals that all chunks of data to be decoded have been submitted.
Returns the decoded data, and clears the state of the $base91 object
so it may be used again (for either encoding or decoding).
=back
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/BaseN.pm view on Meta::CPAN
base => 64,
chars => '0-9A-Za-z\-_='
);
# encode and decode
$encoded = $cb->encode($data);
$decoded = $cb->decode($encoded);
=head1 EXPORT
Nothing. Instead of that, this module builds I<transcoder object> for
you and you use its C<decode> and C<encode> methods to get the job
lib/Convert/BaseN.pm view on Meta::CPAN
=head2 decode
Does decode
my $decoded = $cb->decode($data)
=head2 encode
Does encode.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/Bencode.pm view on Meta::CPAN
value pairs of the hash.
=head2 Decoding
C<bdecode()> expects to be passed a single scalar containing the bencoded string
to be decoded. Its return value will be either a hash ref, a array ref, or a
scalar, depending on whether the outer most element of the bencoded string
was a dictionary, list, or a string/integer respectivly.
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Convert/BinHex.pm view on Meta::CPAN
guarantee that lines contain 4n encoded characters... and even if there
is one, the BinHex compression algorithm interferes: even when you
can I<decode> one line at a time, you can't necessarily
I<decompress> a line at a time.
For example: a decoded line ending with the byte C<\x90> (the escape
or "mark" character) is ambiguous: depending on the next decoded byte,
it could mean a literal C<\x90> (if the next byte is a C<\x00>), or
it could mean n-1 more repetitions of the previous character (if
the next byte is some nonzero C<n>).
For this reason, a BinHex parser has to be somewhat stateful: you
view all matches for this distribution