Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

A gentle soul to verify a Config::Simple based object?

by monsieur_champs (Curate)
on Sep 28, 2004 at 19:21 UTC ( [id://394724]=perlquestion: print w/replies, xml ) Need Help??

monsieur_champs has asked for the wisdom of the Perl Monks concerning the following question:

Fellows, this piece of code is getting me nutz.
I'm quite sure that this is an unsignificant error (maybe concept?) somewhere.

If you're a gentle soul (or is just interested), and can understand this, please make me a favor and double check it for me?

package RCB::Config; use strict; use warnings; use base qw(Config::Simple Class::Singleton); use constant CONFIG_FILE => '../etc/application.conf'; sub _new_instance{ my $class = shift; die "Config file not found!" unless -f CONFIG_FILE; return ( new RCB::Config( CONFIG_FILE ) or die RCB::Config->error() ); } 1;

Replies are listed 'Best First'.
Re: A gentle soul to verify a Config::Simple based object?
by fglock (Vicar) on Sep 28, 2004 at 20:21 UTC

    Everything tests ok here. How about adding a test for file readability - maybe the user under which you are running can't read the config file?

    die "Config file not readable!" unless -r CONFIG_FILE; # or maybe "-R" ?

    update: this is the code I used for testing:

    my $x = RCB::Config->_new_instance; use Data::Dumper; print Dumper( $x );

      Thank you for this. :-)

      Just found the problem. My sections at the config file had an extra space inside '[' and ']' (I've posted the config a couple of posts before this).

      I found something that could be a documentation bug from Config::Simple: the section names (words surrounded by '[' and ']') had not all the leading and trailing spaces removed from them. Nothing is said about this in the config file. Shall I post a bug report on this?

        Hi,

        I wouldn't consider it a bug in the documentation, but an omission. In any case, please send email to the maintainer asking to have it clarified.

        Jason L. Froebe

        No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Re: A gentle soul to verify a Config::Simple based object?
by VSarkiss (Monsignor) on Sep 28, 2004 at 19:49 UTC

    I'd be glad to help, but I don't know how.

    What is the code (a) supposed to be doing, and (b) actually doing? In other words, what do you expect it to do, and what is different from your expectations?

      Thank you. I'm sorry about not telling a lot. All I have is that this "just fails".

      I'm trying to parse this configuration file:

      And I allways get an undef value at the end.

      Any kind of suggestions would be nice.

      Thank you very much and may the gods bless you for this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://394724]
Approved by kutsu
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found