view release on metacpan or search on metacpan
t/02-perl.t view on Meta::CPAN
[
131, 104, 3, 100, 0, 4, 98, 101, 114, 116, 100, 0, 4, 100, 105, 99, 116,
108, 0, 0, 0, 1, 104, 2, 109, 0, 0, 0, 2, 111, 115, 109, 0, 0, 0, 5, 108,
105, 110, 117, 120, 106
], 'hash encode');
my $decoded = decode_bert($bert);
isa_ok($decoded, 'BERT::Dict');
is_deeply($decoded, BERT::Dict->new([ os => 'linux' ]), 'hash decode');
my %decoded = @{ $decoded->value };
is_deeply(\%decoded, $perl, 'hash decode');
# ordered hash
SKIP: {
eval { require Tie::IxHash };
skip 'Tie::IxHash not install', 4 if $@;
t/02-perl.t view on Meta::CPAN
131, 104, 3, 100, 0, 4, 98, 101, 114, 116, 100, 0, 4, 100, 105, 99, 116,
108, 0, 0, 0, 2, 104, 2, 109, 0, 0, 0, 5, 102, 110, 97, 109, 101, 109, 0,
0, 0, 4, 74, 117, 97, 110, 104, 2, 109, 0, 0, 0, 5, 108, 110, 97, 109,
101, 109, 0, 0, 0, 5, 84, 97, 109, 97, 100, 106
], 'ordered hash encode');
my $decoded = decode_bert($bert);
isa_ok($decoded, 'BERT::Dict');
is_deeply($decoded, BERT::Dict->new([ fname => 'Juan', lname => 'Tamad' ]), 'ordered hash decode');
my %decoded = @{ $decoded->value };
is_deeply(\%decoded, $perl, 'ordered hash decode');
}
view all matches for this distribution
view release on metacpan or search on metacpan
Returns an (unsorted) array of pids of all the running processes
on the system. Note: fleet-footed processes may have disappeared
between the time the snapshot is taken and the time the code
subsequently gets around to asking for more information about
them. On the other hand, getting this list is very fast. If you
want the set of current processes on the system decoded as
C<BSD::Process> objects, you should be looking at the C<all>
meta-constructor.
The routine C<list> is not exportable. It may be exported under
the name C<process_info>.
Amount of real time used by the children processes (if any) of the
process. B<F5+>
=item process_flags, flag
A bitmap of process flags (decoded in the following methods as 0
or 1).
=item posix_advisory_lock, advlock
Flag indicating whether the process holds a POSIX advisory lock. B<F5+>
Flag indicating that the process is a session leader. B<F5+>
=item process_status, stat
Numeric value indicating the status of the process, decoded via the
following attibutes. B<F5+>
=item is_being_forked, stat_1
Status indicates that the process is being forked. B<F5+>
view all matches for this distribution
view release on metacpan or search on metacpan
variable represents a heterogeneous collection of values (for
instance, C<kern.clockrate>, C<vm.vmtotal>). In these cases, the
hash key names are reasonably self-explanatory, however, passing
familiarity with kernel data structures is expected.
A certain number of opaque variables are fully decoded (and the
results are returned as hashes), whereas the C<sysctl> binary renders
them as a raw hexdump (for example, C<net.inet.tcp.stats>).
=item sysctl_set
=item iterator
Creates an iterator that may be used to walk through the sysctl
variable tree. If no parameter is given, the iterator defaults
to the first entry of the tree. Otherwise, if a paramter is
given, it is decoded as a sysctl variable. If the decoding
fails, undef is returned.
my $k = BSD::Sysctl->iterator( 'kern' );
while ($k->next) {
print $k->name, '=', $k->value, "\n";
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestUtils.pm view on Meta::CPAN
->allow_bignum
->allow_blessed
->convert_blessed;
sub normalize_json {
my $decoded = $json_codec->decode(shift);
return $json_codec->encode($decoded);
}
sub to_extjson {
my $data = BSON->perl_to_extjson($_[0], { relaxed => $_[1] });
return $json_codec->encode($data);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/BSON.pm view on Meta::CPAN
#pod =attr wrap_dbrefs
#pod
#pod If set to true, during decoding, documents with the fields C<'$id'> and
#pod C<'$ref'> (literal dollar signs, not variables) will be wrapped as
#pod L<BSON::DBRef> objects. If false, they are decoded into ordinary hash
#pod references (or ordered hashes, if C<ordered> is true).
#pod
#pod The default is true.
#pod
#pod =cut
lib/BSON.pm view on Meta::CPAN
#pod
#pod $doc = $codec->decode_one( $byte_string );
#pod $doc = $codec->decode_one( $byte_string, \%options );
#pod
#pod Takes a byte string with a BSON-encoded document and returns a
#pod hash reference representing the decoded document.
#pod
#pod An optional hash reference of options may be provided. Valid options include:
#pod
#pod =for :list
#pod * dt_type â overrides codec default
lib/BSON.pm view on Meta::CPAN
=head2 wrap_dbrefs
If set to true, during decoding, documents with the fields C<'$id'> and
C<'$ref'> (literal dollar signs, not variables) will be wrapped as
L<BSON::DBRef> objects. If false, they are decoded into ordinary hash
references (or ordered hashes, if C<ordered> is true).
The default is true.
=head2 wrap_numbers
lib/BSON.pm view on Meta::CPAN
$doc = $codec->decode_one( $byte_string );
$doc = $codec->decode_one( $byte_string, \%options );
Takes a byte string with a BSON-encoded document and returns a
hash reference representing the decoded document.
An optional hash reference of options may be provided. Valid options include:
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/BT368i/NMEA/GP/GGA.pm view on Meta::CPAN
Parse a GPGGA sentance.
=item $gga->print();
Print a decoded output of a GPGGA sentance.
=item $gga->log($filename);
Log the GPGGA sentance to a file.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Backblaze/B2/v1/AnyEvent.pm view on Meta::CPAN
my $res = $b2->json_request(...)->then(sub {
my( $ok, $message, @stuff ) = @_;
});
Helper routine that expects a JSON formatted response
and returns the decoded JSON structure.
=cut
sub json_request {
my( $self, %options ) = @_;
lib/Backblaze/B2/v1/AnyEvent.pm view on Meta::CPAN
)->then(sub {
my( $body, $headers ) = @_;
my $d = deferred;
my @decoded = $self->decode_json_response($body, $headers);
my $result = $d->promise;
$d->resolve( @decoded );
$result
});
}
view all matches for this distribution
view release on metacpan or search on metacpan
zlib/zlib.h view on Meta::CPAN
above on the use in deflateInit2() applies to the magnitude of windowBits.
windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
a crc32 instead of an adler32.
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
is set to null if there is no error message. inflateInit2 does not perform
zlib/zlib.h view on Meta::CPAN
inflateGetHeader() requests that gzip header information be stored in the
provided gz_header structure. inflateGetHeader() may be called after
inflateInit2() or inflateReset(), and before the first call of inflate().
As inflate() processes the gzip stream, head->done is zero until the header
is completed, at which time head->done is set to one. If a zlib stream is
being decoded, then head->done is set to -1 to indicate that there will be
no gzip header information forthcoming. Note that Z_BLOCK can be used to
force inflate() to return immediately after header processing is complete
and before any actual data is decompressed.
The text, time, xflags, and os fields are filled in with the gzip header
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Badger.pm view on Meta::CPAN
Delegates to the L<Badger::Hub> L<codec()|Badger::Hub/codec()> method to
return a L<Badger::Codec> object.
my $base64 = Badger->codec('base64');
my $encoded = $base64->encode($uncoded);
my $decoded = $base64->decode($encoded);
=head2 config()
Delegates to the L<Badger::Hub> L<codec()|Badger::Hub/codec()> method to
return a L<Badger::Config> object. This is still experimental.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/BalanceOfPower/Role/WebMaster.pm view on Meta::CPAN
if ($response->is_success) {
if($bare)
{
return $response->decoded_content;
}
else
{
my $json = JSON->new->allow_nonref;
return $json->decode( $response->decoded_content );
}
}
else {
return undef;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/BankDetails/India.pm view on Meta::CPAN
return if ( !$self->ping_api );
my $request_url = $self->api_url.$ifsc_code;
my $response = $self->user_agent->get($request_url);
$file_name ||= "bankdetails_$ifsc_code.json";
open(my $fh, '>', $file_name) or die $!;
print $fh $response->decoded_content;
close($fh);
}
sub download_xml {
my ($self, $ifsc_code, $file_name) = @_;
return if ( !$self->ping_api );
my $request_url = $self->api_url.$ifsc_code;
my $response = $self->user_agent->get($request_url);
my $response_data = decode_json($response->decoded_content);
$self->_convert_json_boolean($response_data);
my $xml = XMLout($response_data, RootName => 'data', NoAttr => 1);
$file_name ||= "bankdetails_$ifsc_code.xml";
open(my $fh, '>', $file_name) or die $!;
print $fh $xml;
lib/BankDetails/India.pm view on Meta::CPAN
} else {
my $response = $self->user_agent->get($request_url);
my $response_content;
if ($response->is_success) {
$response_content = $response->decoded_content;
} else {
croak "Failed to fetch data: " . $response->status_line;
}
$response_data = decode_json($response_content);
$self->_convert_json_boolean($response_data);
view all matches for this distribution
view release on metacpan or search on metacpan
Initializes the object with a newly scanned string.
=item C<-E<gt>type()>
Returns the type of barcode decoded. For known :CueCat numbers, this
will be ':C1'.
=item C<-E<gt>code()>
Returns the actual number decoded in the barcode. Codes in the
proprietary :CueCat format are converted automatically to a
sequence of digits.
=item C<-E<gt>serial()>
view all matches for this distribution
view release on metacpan or search on metacpan
collect results:
my @symbols = $image->get_symbols();
foreach my $sym (@symbols) {
print("decoded: " . $sym->get_type() . ":" . $sym->get_data());
}
=head1 DESCRIPTION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Beanstalk/Client.pm view on Meta::CPAN
=item B<decoder ([$decoder])>
Set/get the serialization decoder. C<$decoder> is a reference to a
subroutine that will be called when data from the beanstalkd server needs to be
decoded. The subroutine will be passed the data fetched from the beanstalkd
server and should return a list of values the application can use.
(Default: YAML::Syck::Load)
=item B<error>
view all matches for this distribution
view release on metacpan or search on metacpan
share/SpamAssassin/easy_ham/00204.5c64400ff51925eb0ca4bc7bdab0bc09 view on Meta::CPAN
hextab ["4"] = 4; hextab ["C"] = 12;
hextab ["5"] = 5; hextab ["D"] = 13;
hextab ["6"] = 6; hextab ["E"] = 14;
hextab ["7"] = 7; hextab ["F"] = 15;
decoded = "";
i = 1;
len = length (str);
while ( i <= len ) {
c = substr (str, i, 1);
# check for usual start of URI hex encoding chars
share/SpamAssassin/easy_ham/00204.5c64400ff51925eb0ca4bc7bdab0bc09 view on Meta::CPAN
}
# + is space apparently
} else if ( c == "+" ) {
c = " "
}
decoded = decoded c;
++i;
}
return decoded
}
> Cheers,
> Dave.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bencode.pm view on Meta::CPAN
use Bencode qw( bencode bdecode );
my $bencoded = bencode { 'age' => 25, 'eyes' => 'blue' };
print $bencoded, "\n";
my $decoded = bdecode $bencoded;
=head1 DESCRIPTION
This module implements the BitTorrent I<bencode> serialisation format,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bib/CrossRef.pm view on Meta::CPAN
my $req = HTTP::Request->new(GET => 'https://api.crossref.org/works?mailto=doug@leith.ie&rows=1&query='.$cites_clean);
my $ua = LWP::UserAgent->new;
my $res = $ua->request($req);
if ($res->is_success) {
# extract json response
my $json = decode_json($res->decoded_content);
#use Data::Dumper;
#print Dumper($json->{'message'}{'items'});
my $ref={};
# keep a record of the query string we used
$ref->{'query'} = $cites;
lib/Bib/CrossRef.pm view on Meta::CPAN
my $ua = LWP::UserAgent->new;
my $res = $ua->request($req);
if ($res->is_success) {
# now parse the xml
my $xs = XML::Simple->new();
my $data = $xs->XMLin($res->decoded_content);
my $cite = $data->{'query_result'}->{'body'}->{'query'}->{'doi_record'}->{'crossref'};
my $cc = undef;
if (exists($cite->{'conference'})) {
$self->_setgenre('proceeding');
if (exists($cite->{'conference'}->{'proceedings_metadata'})) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bib/Tools.pm view on Meta::CPAN
$ua->agent('Mozilla/5.0');
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
if ($res->is_success) {
my $tree= HTML::TreeBuilder::XPath->new;
$tree->parse($res->decoded_content);
my @atitles=$tree->findvalues('//tr[@class="gsc_a_tr"]/td/a[@class="gsc_a_at"]');
my @authors=$tree->findvalues('//tr[@class="gsc_a_tr"]/td/div[@class="gs_gray"][1]');
my @jtitles=$tree->findvalues('//tr[@class="gsc_a_tr"]/td/div[@class="gs_gray"][2]');
my $len1 = @atitles; my $len2 = @authors; my $len3 = @jtitles;
if (($len1 != $len2) || ($len1 != $len3) || ($len2 != $len3)) {$self->_err("Problem parsing google page: mismatched $len1 titles/$len2 authors/$len3 journals.");return []}
lib/Bib/Tools.pm view on Meta::CPAN
$ua->agent('Mozilla/5.0');
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
if ($res->is_success) {
my $tree= HTML::TreeBuilder::XPath->new;
$tree->parse($res->decoded_content);
my @atitles=$tree->findvalues('//div[@class="gs_ri"]/h3/a');
my @authors=$tree->findvalues('//div[@class="gs_a"]');
my $len1 = @atitles; my $len2 = @authors;
if ($len1 != $len2) {$self->_err("Problem parsing google page: mismatched $len1 titles/$len2 authors.");return [];}
my @cites=();
lib/Bib/Tools.pm view on Meta::CPAN
$ua->agent('Mozilla/5.0');
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
if ($res->is_success) {
my $xs = XML::Simple->new();
my $data = $xs->XMLin($res->decoded_content);
my @cites; my @ctemp;
if (defined $data->{'r'}) {
# a person page
@cites = $data->{'r'};
} elsif (defined $data->{'article'}) {
lib/Bib/Tools.pm view on Meta::CPAN
my $req = HTTP::Request->new(GET => "http://pub.orcid.org/$orcid_id/orcid-works/");
my $res = $ua->request($req);
if ($res->is_success) {
my $xs = XML::Simple->new();
# the orcid response is utf8 xml
my $data = $xs->XMLin($res->decoded_content);
my @cites = $data->{'orcid-profile'}->{'orcid-activities'}->{'orcid-works'}->{'orcid-work'};
foreach my $cite (@{$cites[0]}) {
my $entry = undef;
if ($cite->{'work-citation'}->{'work-citation-type'} =~ m/bibtex/) {
# we have a bibtex reference, extract some extra info
lib/Bib/Tools.pm view on Meta::CPAN
my $ua = LWP::UserAgent->new;
$q =~ s/\s+/+/g;
my $req = HTTP::Request->new(GET => "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?usehistory=y&db=pubmed&term=".$q);
my $res = $ua->request($req);
if ($res->is_success) {
my $web = $1 if ($res->decoded_content =~ /<WebEnv>(\S+)<\/WebEnv>/);
my $key = $1 if ($res->decoded_content =~ /<QueryKey>(\d+)<\/QueryKey>/);
$req = HTTP::Request->new(GET => "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&query_key=$key&WebEnv=$web");
$res = $ua->request($req);
if ($res->is_success) {
my $xs = XML::Simple->new();
my $data = $xs->XMLin($res->decoded_content);
my @cites = $data->{'DocSum'};
foreach my $cite (@{$cites[0]}) {
my $c = $cite->{'Item'};
if (ref($c) ne "ARRAY") {next;}
my $r = Bib::CrossRef->new;
view all matches for this distribution
view release on metacpan or search on metacpan
To get a feel for how all this works, take a look at the scripts
in the pl/ directory (especially pl/ISO-msg-t-dumper.pm, which creates
the test cases for messages, and pl/ISO-t-dumper.pm, which creates
the test cases for basic types (if you want to dig that deeply)).
Messages are encoded to / decoded from BER-encoded files.
For encoding of messages, the module uses Convert::ASN1, which expects
a hash containing the data. The objects implement an as_asn() method
which returns this hash (and is invoked in the message-type object's
encode() method).
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Biblio/RFID/SmartX.pm view on Meta::CPAN
return unless $data;
die "expecting array of sectors" unless ref $data eq 'ARRAY';
my $decoded;
foreach ( 4 .. 6 ) {
warn "# $_: ",
$decoded->[$_] = bcd( $data->[$_] );
}
my $hash;
$hash->{SXID} = substr( $decoded->[4], 0, 20 );
$hash->{JMBAG} = substr( $decoded->[4], 22, 10 );
$hash->{OIB} = substr( $decoded->[5], 16, 11 );
$hash->{SPOL} = substr( $data->[5], 14, 1 ); # char, not BCD!
$hash->{INST_ID} = substr( $decoded->[6], 0, 12 );
$hash->{CARD_V} = substr( $decoded->[6], 12, 4 );
warn "## hash = ",dump($hash);
return $hash;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bifcode.pm view on Meta::CPAN
# 37 3a 69 6e 74 65 67 65 72 2c 49 32 7:integer,I2
# 35 2c 55 35 3a 75 6e 64 65 66 2c 7e 5,U5:undef,~
# 55 34 3a 75 74 66 38 2c 55 32 3a c3 U4:utf8,U2:.
# 9f 2c 7d .,}
my $decoded = decode_bifcode $bifcode;
=head1 DESCRIPTION
B<Bifcode> implements the I<bifcode> serialisation format, a mixed
binary/text encoding with support for the following data types:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Binance/API/Request.pm view on Meta::CPAN
$response = $self->$method($url, %data);
} else {
$response = $self->$method($url);
}
if ($response->is_success) {
$response = eval { decode_json($response->decoded_content); };
if ($@) {
$self->{logger}->error(
"Error decoding response. \nStatus => " . $response->code . ",\n"
. 'Content => ' . ($response->content ? $response->content : '')
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bing/Translate.pm view on Meta::CPAN
$request->header(Authorization=>$authToken);
my $response = $ua->request($request);
#print $response->as_string, "\n";
if ($response->is_success) {
#print $response->decoded_content;
my $content = $response->decoded_content;
if ($content =~ />(.*)<\/string>/) {
return $1;
}
} else {
return "translate fail";
lib/Bing/Translate.pm view on Meta::CPAN
# my $content = $ua->request($request)->as_string() or die;
my $response = $ua->request($request);
my $content;
my $authToken;
if ($response->is_success) {
#print $response->decoded_content;
$content = $response->decoded_content;
my $accessToken = &decodeJSON($content);
$authToken = "Bearer" . " " . "$accessToken";
} else {
die $response->status_line;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bio/DB/BigWigSet.pm view on Meta::CPAN
unless ($response->is_success) {
warn "Web fetch of $dir failed: ",$response->status_line;
return;
}
my $html = $response->decoded_content;
my $base = $response->base;
my @wigfiles = map {URI::URL->new($_=>$base)->abs} $html =~ /href="([^\"]+\.bw)"/ig;
my @indices = map {URI::URL->new($_=>$base)->abs} $html =~ /href="(meta[^\"]*)"/ig;
return (\@wigfiles,\@indices);
}
lib/Bio/DB/BigWigSet.pm view on Meta::CPAN
my $r = $ua->get($file);
die "Couldn't read $file: ",$r->status_line unless $r->is_success;
eval "require IO::String; 1"
or die "IO::String module is required for remote directories"
unless IO::String->can('new');
$f = IO::String->new($r->decoded_content);
}
else {
$f = IO::File->new($file) or die "$file: $!";
}
my ($current_path,%wigs);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bio/BioVeL/Service.pm view on Meta::CPAN
# location is a URL
if ( $location =~ m#^(?:http|ftp|https)://# ) {
my $ua = LWP::UserAgent->new;
my $response = $ua->get($location);
if ( $response->is_success ) {
my $content = $response->decoded_content;
open my $fh, '<', \$content;
return $fh;
}
}
else {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bio/EBI/RNAseqAPI.pm view on Meta::CPAN
my $response = $userAgent->get( $url );
# If the request was successful, return the parsed JSON.
if( $response->is_success ) {
return parse_json( $response->decoded_content );
}
# Otherwise, log an error and return undef.
else {
$logger->error(
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/Utils/Net.pm view on Meta::CPAN
my ($url) = @_;
throw "Cannot perform action as LWP::UserAgent is not available" unless $LWP;
my $ua = LWP::UserAgent->new();
$ua->env_proxy;
my $response = $ua->get($url);
return $response->decoded_content if $response->is_success;
return;
}
sub _get_lwp_to_file {
my ($url, $filename) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
scripts/get_abundance_profile view on Meta::CPAN
if ($res->is_success){
if ($res->header('Content-Type') eq "application/json") {
my $json = JSON->new->allow_nonref;
my $biom = $json->decode( $res->decoded_content );
# transform biom into plain list
if ($biom->{matrix_type} eq "dense" and $format eq "plain"){
my $counter = 0;
scripts/get_abundance_profile view on Meta::CPAN
$counter++;
exit if ($debug and $counter == 20) ;
}
}
else{
print $res->decoded_content , "\n";
}
}
else{
print $res->decoded_content , "\n";
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Bio/Phylo/NeXML/Entities.pm view on Meta::CPAN
Bio::Phylo::NeXML::Entities - Functions for dealing with XML entities
=head1 DESCRIPTION
This package provides subroutines for dealing with characters that need to be
encoded as XML entities, and decoded in other formats. For example: C<&> needs
to be encoded as C<&> in XML. The subroutines have the same signatures and
the same names as those in the commonly-used module L<HTML::Entities>. They are
re-implemented here to avoid introducing dependencies.
=head1 SUBROUTINES
lib/Bio/Phylo/NeXML/Entities.pm view on Meta::CPAN
Decodes XML entities into the characters they code for
Type : Utility function
Title : decode_entities
Usage : my $decoded = decode_entities('string with & or >')
Function: decodes encoded entities in argument string(s)
Returns : Array of decoded strings
Args : One or more encoded strings
=back
=head1 SEE ALSO
view all matches for this distribution