|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Config::Yacp;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {  | 
| 
3
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
133516
 | 
   use Object::InsideOut;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
348037
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
    | 
| 
4
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
9836
 | 
   use Parse::RecDescent;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
270691
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
49
 | 
    | 
| 
5
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
249
 | 
   use Fcntl qw/:flock/;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
946
 | 
    | 
| 
6
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
31
 | 
   use Carp;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
338
 | 
    | 
| 
7
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
25
 | 
   use strict;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
158
 | 
    | 
| 
8
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
6412
 | 
   use Data::Dumper;  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
42458
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
449
 | 
    | 
| 
9
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
50
 | 
   use vars qw($VERSION $grammar $CONFIG);  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
455
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   $VERSION='2.00';  | 
| 
12
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
1206
 | 
   BEGIN{ $::RD_AUTOACTION=q{ [@item[1..$#item]] }; }  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # Define the grammar  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   $grammar = q(  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                  file: section(s)  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                  section: header pair(s?)  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                  header:  /\[(\w+)\]/ { $1 }  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                  pair:    /(\w+)\s?=\s?(\w+)?(\s+[;#][\s\w]+)?\n/  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                  {  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                    if(!defined $3){  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                      [$1,$2];  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                    }else{  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                      [$1,$2,$3];  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                    }   | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                  }  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
               );  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   my @FileName      :Field('Standard'=>'FileName','Type'=>'LIST');  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   my @CommentMarker :Field('Standard'=>'CommentMarker','Type'=>'LIST');  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   my %init_args :InitArgs=(  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     'FileName'=>{  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         'Regex' => qr/^FileName$/i,  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	'Mandatory' => 1,  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     },  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     'CommentMarker'=>{  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         'Regex' => qr/^CommentMarker$/i,  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	'Default' => '#',  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub _init :Init{  | 
| 
43
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5886
 | 
     my ($self,$args)=@_;  | 
| 
44
 | 
8
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
37
 | 
     if(exists($args->{'FileName'})){  | 
| 
45
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
       $self->set(\@FileName,$args->{'FileName'});  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
47
 | 
8
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
357
 | 
     if(exists($args->{'CommentMarker'})){  | 
| 
48
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
38
 | 
       $self->set(\@CommentMarker,$args->{'CommentMarker'});  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
50
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
460
 | 
     my $cm=$self->get_CommentMarker;  | 
| 
51
 | 
8
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
92
 | 
     if($cm!~/[#;]/){  | 
| 
52
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
295
 | 
       croak "Incorrect Comment Marker detected. Use either # or ; to mark comments";  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
54
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
78
 | 
     my $parser = Parse::RecDescent->new($grammar);  | 
| 
55
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
110261
 | 
     my $file=$self->get_FileName;  | 
| 
56
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
72
 | 
     my $ini;  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     {  | 
| 
58
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
27
 | 
       no strict 'subs';  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
965
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
    | 
| 
59
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
       $/=undef;  | 
| 
60
 | 
7
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
555
 | 
       open(FILE,"$file")||croak "Can't open $file: $!";  | 
| 
61
 | 
7
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
94
 | 
       flock(FILE,LOCK_SH) or die "Unable to obtain a file lock: $!\n";  | 
| 
62
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
203
 | 
       $ini=;  | 
| 
63
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
44
 | 
       flock(FILE,LOCK_UN);  | 
| 
64
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
142
 | 
       close FILE;  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
67
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
135
 | 
     my $tree = $parser->file($ini);  | 
| 
68
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
26558
 | 
     $CONFIG = deparse($tree);  | 
| 
69
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
28
 | 
   }  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
100
 | 
    | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub retrieve_sections{  | 
| 
72
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
562
 | 
     my @sections = sort keys %$CONFIG;  | 
| 
73
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     return @sections;  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub retrieve_parameters{  | 
| 
77
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
733
 | 
     my ($self,$section)=@_;  | 
| 
78
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
216
 | 
     croak "No section given" if !defined $section;  | 
| 
79
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
20
 | 
     croak "Non-existent section given" if !exists $CONFIG->{$section};  | 
| 
80
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     my @params = sort keys %{$CONFIG->{$section}};  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
28
 | 
    | 
| 
81
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
     return @params;  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub retrieve_value{  | 
| 
85
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
0
  
 | 
252
 | 
     my($self,$section,$parameter)=@_;  | 
| 
86
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     croak "Missing arguments" if scalar @_ < 3;  | 
| 
87
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     croak "Non-existent section given" if !exists $CONFIG->{$section};  | 
| 
88
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     croak "Non-existent parameter given" if !exists $CONFIG->{$section}->{$parameter};  | 
| 
89
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     my $value=$CONFIG->{$section}->{$parameter}->[0];  | 
| 
90
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     return $value;  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub change_value{  | 
| 
94
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
0
  
 | 
478
 | 
     my($self,$section,$parameter,$value)=@_;  | 
| 
95
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     croak "Missing arguments" if scalar @_ < 4;  | 
| 
96
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     croak "Non-existent section given" if !exists $CONFIG->{$section};  | 
| 
97
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     croak "Non-existent parameter given" if !exists $CONFIG->{$section}->{$parameter};  | 
| 
98
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
     $CONFIG->{$section}->{$parameter}->[0]=$value;  | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub retrieve_comment{  | 
| 
102
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
  
0
  
 | 
1172
 | 
     my($self,$section,$parameter)=@_;  | 
| 
103
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
17
 | 
     croak"Missing arguments" if scalar @_ < 3;  | 
| 
104
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
17
 | 
     croak"Invalid section argument" if !exists $CONFIG->{$section};  | 
| 
105
 | 
4
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
     croak"Invalid parameter argument" if !exists $CONFIG->{$section}->{$parameter};  | 
| 
106
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     if (!defined $CONFIG->{$section}->{$parameter}->[1]){  | 
| 
107
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
7
 | 
       local $SIG{__WARN__}=sub{ $@=shift; };  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
97
 | 
    | 
| 
108
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
175
 | 
       carp"No comment available for this parameter";  | 
| 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }else{  | 
| 
110
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
       my $comment=$CONFIG->{$section}->{$parameter}->[1];  | 
| 
111
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
       return $comment;  | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
114
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub add_section{  | 
| 
116
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
0
  
 | 
987
 | 
     my ($self,$section)=@_;  | 
| 
117
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
14
 | 
     croak"Missing arguments" if scalar @_ < 2;  | 
| 
118
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
184
 | 
     croak"Section exists!" if exists $CONFIG->{$section};  | 
| 
119
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     $CONFIG->{$section}=undef;    | 
| 
120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
122
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub add_parameter{  | 
| 
123
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
0
  
 | 
1094
 | 
     my ($self,$section,$para,$value,$comment)=@_;  | 
| 
124
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     croak"Missing arguments" if scalar @_ < 4;  | 
| 
125
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     if(!exists $CONFIG->{$section}){  | 
| 
126
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
       $self->add_section($section);  | 
| 
127
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
128
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     croak"Parameter exists" if exists $CONFIG->{$section}->{$para};  | 
| 
129
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $CONFIG->{$section}->{$para}=[$value];  | 
| 
130
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
     if(defined $comment){ push @{$CONFIG->{$section}->{$para}},$comment; }   | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
131
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
132
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub add_comment{  | 
| 
134
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
0
  
 | 
462
 | 
     my ($self,$section,$para,$comment)=@_;  | 
| 
135
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     croak"Missing arguments" if scalar @_ < 4;   | 
| 
136
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     croak"Non-Existent section" if !exists $CONFIG->{$section};  | 
| 
137
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     croak"Non-Existent parameter" if !exists $CONFIG->{$section}->{$para};  | 
| 
138
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     $CONFIG->{$section}->{$para}->[1]=$comment;  | 
| 
139
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
140
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
141
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub display_config{  | 
| 
142
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     print Dumper($CONFIG);  | 
| 
143
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
144
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
145
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub delete_section{  | 
| 
146
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
0
  
 | 
723
 | 
     my ($self,$section)=@_;  | 
| 
147
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     croak"Missing arguments" if scalar @_ < 2;  | 
| 
148
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
11
 | 
     croak"Non-Existent section" if !exists $CONFIG->{$section};  | 
| 
149
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     delete $CONFIG->{$section};  | 
| 
150
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
151
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
152
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub delete_parameter{  | 
| 
153
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
0
  
 | 
433
 | 
     my ($self,$section,$para)=@_;  | 
| 
154
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     croak"Missing arguments" if scalar @_ < 3;  | 
| 
155
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     croak"Non-Existent section" if !exists $CONFIG->{$section};  | 
| 
156
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     croak"Non-Existent parameter" if !exists $CONFIG->{$section}->{$para};  | 
| 
157
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6893
 | 
     delete $CONFIG->{$section}->{$para};  | 
| 
158
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
159
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
160
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub delete_comment{  | 
| 
161
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
  
0
  
 | 
843
 | 
     my ($self,$section,$para)=@_;  | 
| 
162
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     croak"Missing arguments" if scalar @_ < 3;  | 
| 
163
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     croak"Non-Existent section" if !exists $CONFIG->{$section};  | 
| 
164
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
     croak"Non-Existent parameter" if !exists $CONFIG->{$section}->{$para};  | 
| 
165
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     if(defined $CONFIG->{$section}->{$para}->[1]){  | 
| 
166
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
       pop @{$CONFIG->{$section}->{$para}};  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
167
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }else{  | 
| 
168
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
9
 | 
       local $SIG{__WARN__}=sub{ $@=shift; };  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
94
 | 
    | 
| 
169
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
174
 | 
       carp"No comment located for that parameter";  | 
| 
170
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
171
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
172
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
173
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub save{  | 
| 
174
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
 
 | 
6794
 | 
     no strict "refs";  | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
 
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2489
 | 
    | 
| 
175
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
     my $self=shift;  | 
| 
176
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     my $file=$self->get_FileName;  | 
| 
177
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     my $CM=$self->get_CommentMarker;  | 
| 
178
 | 
0
 | 
 
 | 
  
  0
  
 | 
 
 | 
 
 | 
0
 | 
     open FH,">$file"||die"Unable to open $file: $!\n";  | 
| 
179
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     flock(FH,LOCK_EX) or die "Unable to obtain file lock: $!\n";  | 
| 
180
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     foreach my $section(sort keys %{$CONFIG}){  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
181
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
       print FH "[$section]\n";  | 
| 
182
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
       foreach my $para(sort keys %{$CONFIG->{$section}}){  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
183
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
         print FH "$para = $CONFIG->{$section}{$para}[0]";  | 
| 
184
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	if(defined $CONFIG->{$section}{$para}[1]){  | 
| 
185
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	  print FH "    $CM$CONFIG->{$section}{$para}[1]\n";  | 
| 
186
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}else{  | 
| 
187
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
 	  print FH "\n";  | 
| 
188
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	}  | 
| 
189
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       }  | 
| 
190
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
       print FH "\n";  | 
| 
191
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
192
 | 
0
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     flock(FH,LOCK_UN) or die"Unable to unlock file: $!\n";  | 
| 
193
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
     close FH;  | 
| 
194
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
195
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
196
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   sub deparse{  | 
| 
197
 | 
7
 | 
 
 | 
 
 | 
  
7
  
 | 
  
0
  
 | 
15
 | 
     my $tree=shift;  | 
| 
198
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
116
 | 
     my $deparsed={};  | 
| 
199
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
       for my $aref(@$tree){  | 
| 
200
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
         for my $sec(@$aref){  | 
| 
201
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41
 | 
           my $hash=$deparsed->{$sec->[0]}={};  | 
| 
202
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
           for my $aref(@{$sec->[1]}){  | 
| 
 
 | 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
    | 
| 
203
 | 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
84
 | 
 	    $hash->{$aref->[0]}=[$aref->[1]];  | 
| 
204
 | 
29
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
90
 | 
 	    if(my $cmmnt=$aref->[2]){  | 
| 
205
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
54
 | 
 	      $cmmnt=~s/^\s+[#;]//;  | 
| 
206
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
               push @{$hash->{$aref->[0]}},$cmmnt;  | 
| 
 
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
    | 
| 
207
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
208
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
           }  | 
| 
209
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
210
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       }  | 
| 
211
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
79
 | 
     return $deparsed;  | 
| 
212
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
213
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
214
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
215
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |