NAME

Config::DotNetXML - Get config in the manner of .NET Framework

ABSTRACT

This module allows the transparent import of .NET Framework style config.

SYNOPSIS

use Config::DotNetXML;

our %appSettings;

my $foo = $appSettings{Foo};

DESCRIPTION

This module attempts to provide a configuration facility similar to that provided by System.Configuration.ConfigurationSettings class in the .NET framework, the intent is that .NET programs and Perl programs can share the same configuration file.

When the modules import() method is called (either implicitly via use or explicitly) it will read and parse and XML file (by default called $0.config) in the same directory as the script and import the settings specified in that file into the %appSettings hash in the current package.

The XML file is of the format:

<configuration>
   <appSettings>
      <add key="msg" value="Bar" />
   </appSettings>
</configuration>

The <add>elements are the ones that contain the configuration, with the 'key' attribute becoming the key in %appSettings and 'value' becoming the value.

The default behaviour of the module can be altered by the following parameters that are supplied via the import list of the module:

Package

Alter the package into which the settings are imported. The default is the package in which use Config::DotNetXML is called.

VarName

Use a different name for the variable into which the settings are placed. The default is %appSettings, the name should not have the type specifier.

File

Use a different filename from which to get the settings. The default is the program name with '.config' appended.

Section

By default the configuration is taken from the 'appSettings' section of the file - however this can be changed by this parameter. See Config::DotNetXML::Parser for details on named sections.

If you don't want or need the import you should use the Config::DotNetXML::Parser module which is part of this package instead.

BUGS

Those familiar with the .NET Framework will realise that this is not a complete implementation of all of the facilities offered by the System.Configuration class: this will come later.

Some may consider the wanton exporting of names into the calling package to be a bad thing.

SEE ALSO

perl, .NET Framework documentation

AUTHOR

Jonathan Stowe <jns@gellyfish.co.uk>

COPYRIGHT

This library is free software - it comes with no warranty whatsoever.

Copyright (c) 2004, 2005, 2016 Jonathan Stowe

This module can be distributed under the same terms as Perl itself.