Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Simon (89)

AOL IM: lathosjp (Add Buddy, Send Message)

Busy Man.

Journal of Simon (89)

Wednesday July 03, 2002
12:14 PM


[ #6155 ]
I want to go home, but I've got started hacking a really neat little Perl module, and I've only got two subroutines left to do. In fact, stuff it, I'm going home. I can finish this off tomorrow.

So, about the module. It's called Config::Auto, and I've written it because I never want to write another config file parser ever again. So, this little baby looks around for a likely-looking config file, sniffs it to work out what sort of format it's in, and has a good shot at parsing it into a Perl data structure. It deals with XML, INI files, Perl files, lists and the more "vague" Unix-style colon-separated, equal-separated and space-separated files.

For instance:

use Config::Auto; use Data::Dumper;
print Dumper(Config::Auto::parse());

This looks around my filesystem, and finds .tortuousrc, which looks like this:

test: foo=bar, baz=quuz
test2: blah
blez: quux

And, with no other prompting, it comes back with:

$VAR1 = {
            'test2' => 'blah',
            'blez' => 'quux',
            'test' => {
                        'foo' => 'bar',
                        'baz' => 'quuz'

Laziness: check.
Impatience: check.
Hubris: check.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • But wait, you can't finish it tomorrow, because that's a holiday! <stupid-grin/>

    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
  • Did you use YAML?

    FWIW, I write my config files *in* Perl, and just do/require them.  :-) I do like where you're going here, though  ...