Awanti
Awanti

Reputation: 109

perl configuration files reading

Hi i am doing the perl configuration files using Config::Simple And my configuration file is

[Dialer External]
pass=pass2
user=user2

[Dialer Onboard]
pass=pass1
user=user1

Now my actual requirement is that i have to read the comment lines also. If i have file like this

[Dialer External]
pass=pass2
user=user2

[Dialer Onboard]
pass=pass1
;user=user1

I will be able to read the line ;user=user1 also.I know it is not fair to read the comments. But is there any way to read and write the data in comment line.With the help of Config::Simple i guess it is not possible to do this.

Is there any way to do like this in perl. please suggest and correct me in this regard. Thanks in advance.

Upvotes: 1

Views: 203

Answers (2)

Dave Cross
Dave Cross

Reputation: 69314

You could try removing the semicolon on this line of the source code. But you would also need to then remove semicolons from the start of option names.

Upvotes: 1

Gewure
Gewure

Reputation: 1268

Ofcourse this is possible - but rather not with the module Config::Simple as it is now. I just read in the CPAN that 'Retaining comments while writing the configuration files back and/or methods for manipulating comments. Everyone loves comments!' is a TODO of this module right now.

have you digged in the source? it should be rather simple to manipulate the read() in such a way that ;-prefixed lines are not ignored, but aswell pushed into the hash.

Upvotes: 0

Related Questions