© Moritz Lenz 2017

Moritz Lenz, Perl 6 Fundamentals , https://doi.org/10.1007/978-1-4842-2899-9_9

9. Parsing INI Files Using Regexes and Grammars

Moritz Lenz

(1)Fürth, Bayern, Germany

You’ve probably seen .ini files before; they are quite common as configuration files on the Microsoft Windows platform, but are also found in many other places such as ODBC configuration files, Ansible’s inventory files,1 and so on.

This is what they look like:

key1=value2[section1]              key2=value2key3 = with spaces; comment lines start with a semicolon, and are              ; ignored by the parser              [section2]              more=stuff

Perl 6 offers regexes for parsing, and grammars for structuring and reusing regexes.

You could use the Config::INI 2 module (after installing with zef install Config::INI ...

Get Perl 6 Fundamentals : A Primer with Examples, Projects, and Case Studies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.