| 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 | ▶ | use strict qw(vars) ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | no warnings ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | our $VERSION = '1.0' ; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | ############## | ||||||||||||||||||||||||||||
| 21 | # PARSE_ARGS # | ||||||||||||||||||||||||||||
| 22 | ############## | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub parse_args { | ||||||||||||||||||||||||||
|
Subroutine
parse_args: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 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} } ; | |||||||||||||||||||||||||||
| 30 | 0 | my $def ; | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | if (ref $aliases[0] eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | $def = $aliases[-1] ; | |||||||||||||||||||||||||||
| 33 | 0 | @aliases = @{ $aliases[0] } ; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | my $was_set ; | |||||||||||||||||||||||||||
| 37 | 0 | foreach my $aliases_i ( @aliases ) { | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ( defined $args{$aliases_i} ) { $$set{$Key} = $args{$aliases_i} ; $was_set = 1 ; last ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (! $was_set && defined $def) { $$set{$Key} = $def ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $was_set and defined $def
MC/DC0%0/2
not $was_set and defined $def
not $was_set
defined $def
Truth table0%0/3
not(A) and B
A= not $was_setB= defined $def
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | ############# (SCALAR|ARRAY|HASH REF \[$%@]var) | ||||||||||||||||||||||||||||
| 47 | # PARSE_REF # Parse the reference of a var. | ||||||||||||||||||||||||||||
| 48 | ############# (@ARRAY) | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub parse_ref { | ||||||||||||||||||||||||||
|
Subroutine
parse_ref: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 0 | my $ref = ref($_[0]) ; | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($ref eq '') { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (! wantarray) { return( $_[0] ) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | return( @_ ) | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (! wantarray) { return( (@{$_[0]})[0] ) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | return( @{$_[0]} ) | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | elsif ($ref eq 'HASH') { | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (! wantarray) { return( (%{$_[0]})[0] ) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | return( %{$_[0]} ) | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | elsif ($ref eq 'SCALAR') { | ||||||||||||||||||||||||||||
| 65 | 0 | return( ${$_[0]} ) | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if (! wantarray) { return( $_[0] ) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | return( @_ ) | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | ############## | ||||||||||||||||||||||||||||
| 74 | # LOWER_KEYS # | ||||||||||||||||||||||||||||
| 75 | ############## | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub lower_keys { | ||||||||||||||||||||||||||
|
Subroutine
lower_keys: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | 0 | my @hash = parse_ref(@_) ; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | for(my $i = 0 ; $i <= $#hash ; $i +=2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $hash[$i] = lc($hash[$i]) ; | |||||||||||||||||||||||||||
| 82 | 0 | $hash[$i] =~ s/[\W_]//gs ; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( @hash % 2 ) { push(@hash , undef) ;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | return( @hash ) ; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | ######## | ||||||||||||||||||||||||||||
| 91 | # PATH # | ||||||||||||||||||||||||||||
| 92 | ######## | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub path { | ||||||||||||||||||||||||||
|
Subroutine
path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 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 | 1; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||