line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Octets; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: TT2 plugin to format numeric values as binary octets |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
62862
|
use 5.008009; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
47
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
8
|
1
|
|
|
1
|
|
6
|
use base 'Template::Plugin::Procedural'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1030
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.18'; # VERSION |
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
2150
|
use constant KIBIO_DIV => 1024; # 1 KBio |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
14
|
1
|
|
|
1
|
|
5
|
use constant MIBIO_DIV => 1024*1024; # 1 MBio |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
15
|
1
|
|
|
1
|
|
5
|
use constant GIBIO_DIV => 1024*1024*1024; # 1 GBio |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
225
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# kibioctets |
19
|
3
|
|
|
3
|
1
|
134349
|
sub kio { _formatter(KIBIO_DIV, $_[0]) } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
# mebioctets |
23
|
2
|
|
|
2
|
1
|
7526
|
sub mio { _formatter(MIBIO_DIV, $_[0]) } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# gibioctets |
27
|
2
|
|
|
2
|
1
|
7745
|
sub gio { _formatter(GIBIO_DIV, $_[0]) } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# Format octets |
31
|
|
|
|
|
|
|
sub _formatter { |
32
|
7
|
|
|
7
|
|
15
|
my ($divider, $value) = @_; |
33
|
|
|
|
|
|
|
|
34
|
7
|
100
|
66
|
|
|
52
|
$value = 0 if $value eq '' or !defined $value; |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
94
|
$value = sprintf '%.1f', $value/$divider; |
37
|
|
|
|
|
|
|
|
38
|
7
|
100
|
|
|
|
41
|
return '~0' if $value eq '0.0'; |
39
|
3
|
|
|
|
|
15
|
return $value; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; # End of Template::Plugin::Octets |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |