| 1 | package Log::Saftpresse::Utils; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | # ABSTRACT: class with collection of some utility functions | ||||||||||||||
| 7 | 1 | our $VERSION = '1.5'; # VERSION | |||||||||||||
| 8 | |||||||||||||||
| 9 | 1 | ▶ | use Log::Saftpresse::Constants; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | 1 | our (@ISA, @EXPORT_OK); | |||||||||||||
| 12 | |||||||||||||||
| 13 | BEGIN { | ||||||||||||||
| 14 | 1 | ▶ | require Exporter; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | |||||||||||||||
| 16 | 1 | @ISA = qw(Exporter); | |||||||||||||
| 17 | 1 | @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 | ▶ | my $value = $_[0]; | ||||||||||||
|
Subroutine
adj_int_units: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 23 | 0 | my $units = ' '; | |||||||||||||
| 24 | 0 | ▶ | $value = 0 unless($value); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 0 | ▶ | if($value > $divByOneMegAt) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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 | ▶ | my $value = $_[0]; | ||||||||||||
|
Subroutine
adj_time_units: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 38 | 0 | my $units = 's'; | |||||||||||||
| 39 | 0 | ▶ | $value = 0 unless($value); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 0 | ▶ | if($value > 3600) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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 | ▶ | my $sec = shift @_; | ||||||||||||
|
Subroutine
get_smh: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 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 | 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 | ||||||||||||||