annotate lib/conf.pm @ 0:be582bcd6585 draft

Master branch Updating - - Fxx
author fgiacomoni
date Thu, 04 Oct 2018 10:37:14 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
1 package lib::conf ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
2
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
3 use strict;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
4 use warnings ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
5 use Exporter ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
6 use Carp ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
7 use Data::Dumper ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
8
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
9 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS);
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
10
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
11 our $VERSION = "1.0" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
12 our @ISA = qw(Exporter) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
13 our @EXPORT = qw( as_conf get_value_from_conf check_path_and_file ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
14 our %EXPORT_TAGS = ( ALL => [qw( as_conf get_value_from_conf )] ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
15
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
16 =head1 NAME
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
17
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
18 conf - A module for manage pfem conf file
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
19
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
20 =head1 SYNOPSIS
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
21
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
22 use conf ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
23 my $object = conf->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
24
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
25 =head1 DESCRIPTION
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
26
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
27 This module does manage conf file (extract all or selected fields)
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
28
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
29 =head1 METHODS
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
30
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
31 Methods are :
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
32
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
33 =head2 METHOD new
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
34
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
35 ## Description : new
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
36 ## Input : $self
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
37 ## Ouput : bless $self ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
38 ## Usage : new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
39
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
40 =cut
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
41 ## START of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
42 sub new {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
43 ## Variables
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
44 my $self={};
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
45 bless($self) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
46 return $self ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
47 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
48 ### END of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
49
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
50 =head2 METHOD as_conf
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
51
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
52 ## Description : permet de creer l'object conf a partir d'un fichier de conf de type KEY=VALUE
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
53 ## Input : $file
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
54 ## Ouput : $oConf (a hash)
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
55 ## Usage : my ( $oConf ) = as_conf( $file ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
56
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
57 =cut
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
58 ## START of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
59 sub as_conf {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
60 ## Retrieve Values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
61 my $self = shift ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
62 my ( $file, $separator ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
63
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
64 # if (!defined $separator) { $separator = ';' } ## set separator to ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
65
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
66 if ( !defined $file ) { croak "Can't create object with an none defined file\n" ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
67
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
68 my %Conf = () ; ## Hash devant contenir l'ensemble des parametres locaux
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
69
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
70 if (-e $file) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
71 open (CFG, "<$file") or die "Can't open $file\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
72 while (<CFG>) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
73 chomp $_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
74 if ( $_ =~ /^#(.*)/) { next ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
75 elsif ($_ =~/^(\w+?)=(.*)/) { ## ALPHANUMERIC OR UNDERSCORE ONLY FOR THE KEY AND ANYTHING ELSE FOR VALUE
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
76
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
77 my ($key, $value) = ($1, $2) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
78
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
79 if (defined $separator) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
80 if ( $value=~/$separator/ ) { ## is a list to split
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
81 my @tmp = split(/$separator/ , $value) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
82 $Conf{$key} = \@tmp ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
83 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
84 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
85 else {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
86 $Conf{$key} = $value ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
87 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
88 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
89 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
90 close(CFG) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
91 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
92 else {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
93 croak "Can't create object with an none existing file\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
94 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
95
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
96 return ( \%Conf ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
97 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
98 ## END of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
99
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
100 =head2 METHOD as_conf_list
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
101
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
102 ## Description : permet de charger une liste txt en array
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
103 ## Input : $file
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
104 ## Output : elements
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
105 ## Usage : my ( elements ) = as_conf_list( $conf_file ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
106
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
107 =cut
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
108 ## START of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
109 sub as_conf_list {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
110 ## Retrieve Values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
111 my $self = shift ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
112 my ( $file ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
113
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
114 my @elements = () ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
115 if ( !defined $file ) { croak "Can't create object with an none defined file\n" ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
116
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
117 if (-e $file) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
118 open (CFG, "<$file") or die "Can't open $file\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
119 while (<CFG>) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
120 chomp $_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
121 if ( $_ =~ /^#(.*)/) { next ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
122 elsif ($_ =~/^(.*)/) { if (defined $1) { push (@elements, $1) ; } }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
123 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
124 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
125 else {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
126 croak "Can't create object with an none existing file\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
127 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
128 return(\@elements) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
129 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
130 ## END of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
131
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
132 =head2 METHOD get_value_from_conf
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
133
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
134 ## Description : permet de retourner une valeur du hash de conf a partir d'une key
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
135 ## Input : $oConf, $Key
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
136 ## Ouput : $Value
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
137 ## Usage : my ( $Value ) = get_value_from_conf( $oConf, $Key ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
138
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
139 =cut
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
140 ## START of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
141 sub get_value_from_conf {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
142 ## Retrieve Values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
143 my $self = shift ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
144 my ( $oConf, $Key ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
145
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
146 my $Value = undef ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
147
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
148 if ( defined $oConf ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
149 if ( defined $oConf->{$Key} ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
150 $Value = $oConf->{$Key} ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
151 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
152 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
153 else {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
154 croak "Can't manage value with undefined object\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
155 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
156 return($Value) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
157 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
158 ## END of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
159
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
160 =head2 METHOD get_value_from_conf
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
161
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
162 ## Description : permet de retourner une valeur du hash de conf a partir d'une key
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
163 ## Input : $oConf, $Key
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
164 ## Ouput : $Value
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
165 ## Usage : my ( $Value ) = get_value_from_conf( $oConf, $Key ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
166
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
167 =cut
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
168 ## START of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
169 sub split_value_from_conf {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
170 ## Retrieve Values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
171 my $self = shift ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
172 my ( $oConf, $Key, $sep ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
173
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
174 my $value = undef ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
175 my @values = () ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
176
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
177 if ( defined $oConf ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
178 if ( defined $oConf->{$Key} ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
179 $value = $oConf->{$Key} ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
180 @values = split ( /$sep/, $value) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
181 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
182 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
183 else {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
184 croak "Can't manage value with undefined object\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
185 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
186 return(\@values) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
187 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
188 ## END of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
189
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
190
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
191 =head2 METHOD check_path_and_file
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
192
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
193 ## Description : permet de verifier les path et la presence des exe decrits dans le file conf. Bloque le script en cas de probleme
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
194 ## Input : $oConfs
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
195 ## Ouput : NA
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
196 ## Usage : &get_value_from_conf( $oConf ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
197
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
198 =cut
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
199 ## START of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
200 sub check_path_and_file {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
201
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
202 my $self = shift ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
203 my ( $oConfs ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
204
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
205 foreach my $conf ( keys %{ $oConfs } ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
206 if ( $conf =~ /^FILE/ ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
207 if ( -e $oConfs->{$conf} ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
208 if ( -s $oConfs->{$conf} ) { next ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
209 else { carp "[Warning] : The size of file $oConfs->{$conf} is null\n" ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
210 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
211 else {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
212 carp "[Warning] : The file $oConfs->{$conf} doesn't exist\n" ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
213 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
214 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
215 elsif ( $conf =~ /^PATH/ ) {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
216 if ( -d $oConfs->{$conf} ) { next ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
217 else { carp "[Warning] : The dir $oConfs->{$conf} doesn't exist\n" ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
218 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
219 else { next ; }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
220 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
221 return ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
222 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
223 ## END of SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
224
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
225 1 ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
226
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
227
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
228 __END__
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
229
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
230 =head1 SUPPORT
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
231
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
232 You can find documentation for this module with the perldoc command.
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
233
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
234 perldoc conf.pm
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
235
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
236
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
237 =head1 Exports
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
238
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
239 =over 4
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
240
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
241 =item :ALL is as_conf get_value_from_conf
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
242
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
243 =back
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
244
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
245 =head1 AUTHOR
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
246
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
247 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt>
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
248
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
249 =head1 LICENSE
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
250
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
251 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
252
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
253 =head1 VERSION
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
254
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
255 version 1 : 10 / 02 / 2013
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
256
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
257 version 2 : 15 / 12 / 2015
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
258
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
259 =cut