line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Saftpresse::Utils; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
728
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: class with collection of some utility functions |
7
|
|
|
|
|
|
|
our $VERSION = '1.5'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Log::Saftpresse::Constants; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
142
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our (@ISA, @EXPORT_OK); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
1
|
|
|
1
|
|
5
|
require Exporter; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
7
|
@ISA = qw(Exporter); |
17
|
1
|
|
|
|
|
148
|
@EXPORT_OK = qw( &adj_int_units &adj_time_units &get_smh ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Return (value, units) for integer |
21
|
|
|
|
|
|
|
sub adj_int_units { |
22
|
0
|
|
|
0
|
0
|
|
my $value = $_[0]; |
23
|
0
|
|
|
|
|
|
my $units = ' '; |
24
|
0
|
0
|
|
|
|
|
$value = 0 unless($value); |
25
|
0
|
0
|
|
|
|
|
if($value > $divByOneMegAt) { |
|
|
0
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$value /= $oneMeg; |
27
|
0
|
|
|
|
|
|
$units = 'm' |
28
|
|
|
|
|
|
|
} elsif($value > $divByOneKAt) { |
29
|
0
|
|
|
|
|
|
$value /= $oneK; |
30
|
0
|
|
|
|
|
|
$units = 'k' |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
return($value, $units); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Return (value, units) for time |
36
|
|
|
|
|
|
|
sub adj_time_units { |
37
|
0
|
|
|
0
|
0
|
|
my $value = $_[0]; |
38
|
0
|
|
|
|
|
|
my $units = 's'; |
39
|
0
|
0
|
|
|
|
|
$value = 0 unless($value); |
40
|
0
|
0
|
|
|
|
|
if($value > 3600) { |
|
|
0
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$value /= 3600; |
42
|
0
|
|
|
|
|
|
$units = 'h' |
43
|
|
|
|
|
|
|
} elsif($value > 60) { |
44
|
0
|
|
|
|
|
|
$value /= 60; |
45
|
0
|
|
|
|
|
|
$units = 'm' |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
return($value, $units); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Get seconds, minutes and hours from seconds |
51
|
|
|
|
|
|
|
sub get_smh { |
52
|
0
|
|
|
0
|
0
|
|
my $sec = shift @_; |
53
|
0
|
|
|
|
|
|
my $hr = int($sec / 3600); |
54
|
0
|
|
|
|
|
|
$sec -= $hr * 3600; |
55
|
0
|
|
|
|
|
|
my $min = int($sec / 60); |
56
|
0
|
|
|
|
|
|
$sec -= $min * 60; |
57
|
0
|
|
|
|
|
|
return($sec, $min, $hr); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Log::Saftpresse::Utils - class with collection of some utility functions |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 1.5 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software, licensed under: |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |