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