line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
## Name: CORE.pm |
3
|
|
|
|
|
|
|
## Purpose: HDB::CORE |
4
|
|
|
|
|
|
|
## Author: Graciliano M. P. |
5
|
|
|
|
|
|
|
## Modified by: |
6
|
|
|
|
|
|
|
## Created: 06/01/2003 |
7
|
|
|
|
|
|
|
## RCS-ID: |
8
|
|
|
|
|
|
|
## Copyright: (c) 2002 Graciliano M. P. |
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
11
|
|
|
|
|
|
|
############################################################################# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package HDB::CORE ; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
7
|
use strict qw(vars) ; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
16
|
1
|
|
|
1
|
|
5
|
no warnings ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
540
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '1.0' ; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
############## |
21
|
|
|
|
|
|
|
# PARSE_ARGS # |
22
|
|
|
|
|
|
|
############## |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub parse_args { |
25
|
0
|
|
|
0
|
0
|
|
my ( $set , $types ) = @_ ; |
26
|
0
|
|
|
|
|
|
my %args = &lower_keys(@_[2..$#_]) ; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
foreach my $Key ( keys %$types ) { |
29
|
0
|
|
|
|
|
|
my @aliases = @{ $$types{$Key} } ; |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $def ; |
31
|
0
|
0
|
|
|
|
|
if (ref $aliases[0] eq 'ARRAY') { |
32
|
0
|
|
|
|
|
|
$def = $aliases[-1] ; |
33
|
0
|
|
|
|
|
|
@aliases = @{ $aliases[0] } ; |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $was_set ; |
37
|
0
|
|
|
|
|
|
foreach my $aliases_i ( @aliases ) { |
38
|
0
|
0
|
|
|
|
|
if ( defined $args{$aliases_i} ) { $$set{$Key} = $args{$aliases_i} ; $was_set = 1 ; last ;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
0
|
|
|
|
if (! $was_set && defined $def) { $$set{$Key} = $def ;} |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
############# (SCALAR|ARRAY|HASH REF \[$%@]var) |
47
|
|
|
|
|
|
|
# PARSE_REF # Parse the reference of a var. |
48
|
|
|
|
|
|
|
############# (@ARRAY) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub parse_ref { |
51
|
0
|
|
|
0
|
0
|
|
my $ref = ref($_[0]) ; |
52
|
0
|
0
|
|
|
|
|
if ($ref eq '') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if (! wantarray) { return( $_[0] ) } |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return( @_ ) |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif ($ref eq 'ARRAY') { |
57
|
0
|
0
|
|
|
|
|
if (! wantarray) { return( (@{$_[0]})[0] ) } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return( @{$_[0]} ) |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
elsif ($ref eq 'HASH') { |
61
|
0
|
0
|
|
|
|
|
if (! wantarray) { return( (%{$_[0]})[0] ) } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return( %{$_[0]} ) |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif ($ref eq 'SCALAR') { |
65
|
0
|
|
|
|
|
|
return( ${$_[0]} ) |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
0
|
0
|
|
|
|
|
if (! wantarray) { return( $_[0] ) } |
|
0
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return( @_ ) |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
############## |
74
|
|
|
|
|
|
|
# LOWER_KEYS # |
75
|
|
|
|
|
|
|
############## |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub lower_keys { |
78
|
0
|
|
|
0
|
0
|
|
my @hash = parse_ref(@_) ; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
for(my $i = 0 ; $i <= $#hash ; $i +=2) { |
81
|
0
|
|
|
|
|
|
$hash[$i] = lc($hash[$i]) ; |
82
|
0
|
|
|
|
|
|
$hash[$i] =~ s/[\W_]//gs ; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if ( @hash % 2 ) { push(@hash , undef) ;} |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return( @hash ) ; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
######## |
91
|
|
|
|
|
|
|
# PATH # |
92
|
|
|
|
|
|
|
######## |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub path { |
95
|
0
|
|
|
0
|
0
|
|
my ( $path ) = @_ ; |
96
|
0
|
|
|
|
|
|
$path =~ s/[\\]/\//gs ; |
97
|
0
|
|
|
|
|
|
$path =~ s/(?:^(\/)\/([^\/])|\/+)/$1\/$2/gs ; |
98
|
0
|
|
|
|
|
|
return( $path ) ; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
####### |
102
|
|
|
|
|
|
|
# END # |
103
|
|
|
|
|
|
|
####### |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|