line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Labyrinth::Filters; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
47679
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6
|
use vars qw( $VERSION $AUTOLOAD @ISA %EXPORT_TAGS @EXPORT_OK @EXPORT ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
214
|
|
7
|
|
|
|
|
|
|
$VERSION = '5.32'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Labyrinth::Filters - Basic Filters Handler for Labyrinth |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Provides basic filter methods used within Labyrinth. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ------------------------------------- |
20
|
|
|
|
|
|
|
# Export Details |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require Exporter; |
23
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
24
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
25
|
|
|
|
|
|
|
'all' => [ qw( float2 float3 float5 ) ] |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
29
|
|
|
|
|
|
|
@EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
# Libraries |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
319
|
use Labyrinth::Audit; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
248
|
|
35
|
2
|
|
|
2
|
|
360
|
use Labyrinth::Variables; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
# Subroutines |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub float2 { return _filter_float( @_, "%.2f" ) } |
41
|
|
|
|
|
|
|
sub float3 { return _filter_float( @_, "%.3f" ) } |
42
|
|
|
|
|
|
|
sub float5 { return _filter_float( @_, "%.5f" ) } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub filter_float2 { return _filter_float( @_, "%.2f" ) } |
45
|
|
|
|
|
|
|
sub filter_float3 { return _filter_float( @_, "%.3f" ) } |
46
|
|
|
|
|
|
|
sub filter_float5 { return _filter_float( @_, "%.5f" ) } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _filter_float { |
49
|
|
|
|
|
|
|
my ($value,$pattern) = @_; |
50
|
|
|
|
|
|
|
return unless(defined $value); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#LogDebug("filter:value=$value, pattern=$pattern"); |
53
|
|
|
|
|
|
|
my ($num) = $value =~ m< ^ ([\d.]+) $ >x; |
54
|
|
|
|
|
|
|
return unless(defined $num); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#LogDebug("filter:num=$num, val=" . ( sprintf $pattern, $num )); |
57
|
|
|
|
|
|
|
return sprintf $pattern, $num; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub AUTOLOAD { |
63
|
|
|
|
|
|
|
my $name = $AUTOLOAD; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
no strict qw/refs/; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my ($num) = $name =~ m/^.*:(?:filter_)?float(\d+)/; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return unless(defined $num); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $fmt = '%.' . $num . 'f'; |
72
|
|
|
|
|
|
|
return _filter_float( @_, $fmt ) |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |