Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Config::Magic 0.801

    Download button

    No screenshots available
    Downloads: 3,001  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Excellent (5.0/5)
    3 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Rusty Phillips | More programs
    Perl Artistic License / FREE
    April 12th, 2007, 19:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Config::Magic description

    A Perl extension for reading all kinds of configuration files.

    SYNOPSIS

    Example 1

    use Config::Magic;
    use Data::Dumper;

    $input=q{
    Section 1 {
    [Section 4]
    #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' => [
    '1',
    '2',
    '3'
    ]
    },
    'Section' => [
    {
    '2' => {},
    'Foo ' => 'Bar',
    'Baz' => {
    'Bip' => '1',
    'Pants' => '5'
    }
    },
    {
    attribs=>5,
    'Foo' => [
    'Bippity',
    'boppity',
    'boo'
    ]
    }
    ],
    '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.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    read configuration | read config files | Perl module | Config | read | configuration

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM