line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# string::ascii Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::String::Ascii; |
7
|
1
|
|
|
1
|
|
569
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use base qw(Metabrik); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
520
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable encode decode) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
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
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my ($data) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('from_dec', $data) or return; |
29
|
0
|
0
|
|
|
|
|
my $ref = $self->brik_help_run_invalid_arg('from_dec', $data, 'ARRAY', 'SCALAR') |
30
|
|
|
|
|
|
|
or return; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my @data = (); |
33
|
0
|
0
|
|
|
|
|
if ($ref eq 'ARRAY') { |
34
|
0
|
|
|
|
|
|
for my $this (@$data) { |
35
|
0
|
0
|
|
|
|
|
if ($this =~ /^\d+$/) { |
36
|
0
|
|
|
|
|
|
push @data, $this; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
|
$self->log->warning("from_dec: data [$this] is not decimal, skipping"); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
0
|
|
|
|
|
if ($data =~ /^\d+$/) { |
45
|
0
|
|
|
|
|
|
push @data, $data; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
0
|
|
|
|
|
|
$self->log->warning("from_dec: data [$data] is not decimal, skipping"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $str = ''; |
53
|
0
|
|
|
|
|
|
for (@data) { |
54
|
0
|
|
|
|
|
|
$str .= sprintf("%c", $_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $str; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |