String/Ascii.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Shell/Script.pm ↑ Summary String/Base64.pm »
1 #
2 # $Id$
3 #
4 # string::ascii Brik
5 #
6 package Metabrik::String::Ascii;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable encode decode) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 commands => {
19 from_dec => [ qw(data|$data_list) ],
20 },
21 };
22 }
23  
24 sub from_dec {
25 my $self = shift;
26 my ($data) = @_;
27  
28 $self->brik_help_run_undef_arg('from_dec', $data) or return;
29 my $ref = $self->brik_help_run_invalid_arg('from_dec', $data, 'ARRAY', 'SCALAR')
30 or return;
31  
32 my @data = ();
33 if ($ref eq 'ARRAY') {
34 for my $this (@$data) {
35 if ($this =~ /^\d+$/) {
36 push @data, $this;
37 }
38 else {
39 $self->log->warning("from_dec: data [$this] is not decimal, skipping");
40 }
41 }
42 }
43 else {
44 if ($data =~ /^\d+$/) {
45 push @data, $data;
46 }
47 else {
48 $self->log->warning("from_dec: data [$data] is not decimal, skipping");
49 }
50 }
51  
52 my $str = '';
53 for (@data) {
54 $str .= sprintf("%c", $_);
55 }
56  
57 return $str;
58 }
59  
60 1;
61  
62 __END__
« Shell/Script.pm ↑ Summary String/Base64.pm »