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

I'm trying to get Config::Std working on a server for some cgi stuff..

(Not sure where to look for more info on this)

It works great on my workstation(FC kernel 2.6)and on one server (Suse kernel 2.6) - and then.. i have these two other boxes with FreeBSD (no root access to these guys), and i'm having the thing poop out.. I wonder if it's the architectures and not something else???

Test code follows..

my $conf = load_conf(); sub load_conf { my $arg= shift; $arg->{filename} ||= 'site.conf'; unless( -f cwd."/$$arg{filename}" ){ open(CONF, ">".cwd."/$$arg{filename}") or die($!); print CONF define_default_conf(); close CONF; } read_config( "$$arg{filename}" => my %conf); # line 317 return \%conf; } sub define_default_conf { my $defaultconf = <<"DEFAULTCONF"; # config file for site [Paths] # relative to cgi content_dir: $ENV{DOCUMENT_ROOT}/content thumbnails_dir: $ENV{DOCUMENT_ROOT}/.thumbnails metadata_dir: $ENV{DOCUMENT_ROOT}/.metadata templates_dir: $ENV{DOCUMENT_ROOT}/templates [Settings] main_template_filename: template.html request_param: section DEFAULTCONF return $defaultconf; }

I get this error:

Malformed prototype for Config::Std::Hash::read_config: $\%$ at index.cgi line 317.
The file does not get created also- .

Same damn code works perfect on the suse and fedora boxes. Also tried having the files already there (instead of creating defaults.. but same error. I'm so sad.. Config::Std made by *the* DC)

Does anything here look familiar to you?

update Sept 06 2006

Config::Std is nice, but I've had some problems using it in the real world accross different hosting accounts. The reality is that hosts do not maintain their perl and other modules up to date. And we do not always have the choice of where our software runs.

I sadly switched to using CGI::Ex::Conf with YAML which does do the job, and well.

This is sad because Config::Std was made by Damian Conway, who also made Smart::Comments, and wrote Perl Best Practices. ( wow )

Replies are listed 'Best First'.
Re: problem with Config::Std on FreeBSD box?
by imp (Priest) on Aug 25, 2006 at 20:13 UTC
    I can test this on my OpenBSD box if you provide some more information.
    1. Perl version
    2. Config::Std version
    3. Bare minimal runnable example that displays this problem. I can't run the example you provided.
    Also, please read the following:
    How (not) to ask a question - Only Post Relevant Code

      In example.conf:

      # example.conf must sit beside this script # it contains : [settings] a : house b : room

      In example.cgi:

      #!/usr/bin/perl -w use strict; use Config::Std; read_config( 'example.conf' => my %conf ); print STDERR "example.conf: ".$conf{settings}{a}."\n";

      Both files must reside in same directory.

      Box 1, error
      Config::Std version 0.0.4
      perl v5.6.1 built for i386-linux
      freebsd box
      Outputs:

      Malformed prototype for Config::Std::Hash::read_config: $\%$ at example.cgi line 5.

      Box 2, works
      Config::Std version 0.0.4
      perl v5.8.3 built for i586-linux-thread-multi
      suse box

      Box 3, works
      Config::Std version 0.0.4
      perl v5.8.6 built for 86_64-linux-thread-multi
      FC box

      Sorry for the sloppy post..

        Found the problem.

        The prototype being used by Config::Std::read_config isn't supported until perl 5.7.3 - see perl573delta.

        Minimal test case:

        sub read_config ($\[%$]) {} read_config( 'example.conf' => my %conf );
        Works for me in this environment:
        Config::Std version 0.0.4
        perl 5.8.2 built for i386-openbsd 
        OpenBSD 3.5
        
        Installing perl 5.6.2, will update this entry once its done and I can test.
        Why on Earth is your FreeBSD Perl build for i386-linux?

        What version of Perl are you really using on FreeBSD? And what version of FreeBSD is this?