Perl 6 Config::INI on Github
I now have a basic INI file parser written in Perl 6. It's clumsy and I'm quite unsure about packaging. Any and all suggestions welcome, including patches!
The basic usage is like this. Assuming we have an INI file like this (note that we trim leading and trailing whitespace on k/v's and section names):
host = http://localhost/ port = 3333 [admin] ; these only apply to admin users name = Administrator access = all [ anonymous ] name = Guest access = none
We can read it like this:
my Config::INI $config .= new;
$config.read($filename);
# gets the host and port properties
for $config.properties.kv -> $k, $v {
say "$k => $v";
}
# gets the name and access properties under admin
my %admin = $config.properties('admin');
# dies
$config.properties('no_such_section');
Yeah, it needs a lot of work, but Perl 6 still twists my mind from time to time.
If you want to run the tests, make sure your Rakudo is up to date and:
PERL6LIB=lib/ prove --exec perl6 t/
This assumes that you have perl6 installed.
This just popped into my head so forgive me. Are Perl6 and Perl5 modules going to reside in the same CPAN?
@Robert: theoretically they are (from what I've heard), but I don't know how it's going to work in practice. There have been discussions on creating a CP6AN, but nothing's happened that I'm aware of.
I am guessing there will be some kind of META tag to determine that a module is usable for which generation. Otherwise you will have a tidy mess to deal with.
Are Perl6 and Perl5 modules going to reside in the same CPAN?
It has not been defined yet, and really, definitions don't count if people don't do it that way.
Last I knew, there is not a toolchain that installs modules anyway, so where the toolchain gets the modules is moot.
The link is broken. It goes Config-Tiny, but apparently you called it Config-INI.