Config::Magic

Config::Magic is a Perl extension for reading all kinds of configuration files.
Download

Config::Magic Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Rusty Phillips
  • Publisher web site:
  • http://search.cpan.org/~rustyp/Config-Magic-0.801/lib/Config/Magic.pm

Config::Magic Tags


Config::Magic Description

Config::Magic is a Perl extension for reading all kinds of configuration files. SYNOPSISExample 1 use Config::Magic; use Data::Dumper; $input=q{ Section 1 { #Comment style #1 //Comment style #2 ;Comment style #3 Monkey:1 Monkey=>2 Monkey:=3 < Section 2 > Foo = Bar Baz { Bip:1 Pants==5 } < /Section > < Tasty Cheese="3" / > < Section 5 > Foo=Bippity,boppity,boo < /Section > } } #Fastest way: $config = new Config::Magic(); print Dumper($config->parse($input));Example 2 use Config::Magic; use Data::Dumper;#Arguments with sorting $ordered_hash = 1; $config = new Config::Magic("input.conf",$ordered_hash); print Dumper($config->parse); $result = $config->get_result; print Dumper($result);OUTPUT (from second example) 'Section 1' => { 'Section 4' => { 'Monkey' => }, 'Section' => } ], 'Tasty' => { 'Cheese' => { } }This module uses Parse::RecDescent to generate a parse tree for nearly any kind of configuration file. You can even combine files/configuration types. It understands XML, Apache-style, ini files, csv files, and pretty much everything else I could find. Just give it a file, and get a hash tree out. If it doesn't understand the file, or it isn't well formed (such as if a bracket is missing, etc), then you will get a partial result, or no result at all.There is a single option that can be passed to this file which indicates that the resulting hash should be ordered rather than random. This is done using Tie::Hash::Indexed. You can also call "setordered" directly to change from using ordered to unordered hashes. Requirements: · Perl


Config::Magic Related Software