[boulder.pm] line/loop optimization?

Jim Baker boulder-pm at jim-baker.com
Tue May 8 13:08:40 CDT 2001


It's even more fun when you use Data::Dumper to create the config file to
begin with.  Data structure serialization to a self-describing text format
(Perl) is definitely useful.  I'm just awaiting the day when code refs are
not replace with dummy variables!

Finally, there are a number of modules out there to simplify reading/writing
standard config file formats when the format is legacy (ini, X
configuration, /etc/passwd) or you need to interoperate (such as with XML).

- Jim

-----Original Message-----
From: owner-boulder-pm-list at pm.org
[mailto:owner-boulder-pm-list at pm.org]On Behalf Of Rob Nagler
Sent: Tuesday, May 08, 2001 11:46 AM
To: boulder-pm-list at happyfunball.pm.org
Subject: Re: [boulder.pm] line/loop optimization?


Why not use perl itself?  We have lots of config files and they are all
perl, sometimes with one or two substitutions to make it easy.

You could change the syntax to be:

{
   OPTION1 => 'value1',
   OPTION2 => 'value2',
};

Which is parsed by:

    my($info) = do($file);
    die($@) if $@;
    die($file, ": didn't return a hash_ref")
	    unless ref($info) eq 'HASH';

The syntax errors will be clearer, the parser is already debugged,
and it will probably be a lot faster than an custom solution.  If
you need security, use safeperl.

W

Rob




More information about the Boulder-pm mailing list