Config::Trivial::Storable - Very simple tool for reading and writing very simple Storable configuration files


Config-Trivial-Storable documentation  | view source Contained in the Config-Trivial-Storable distribution.

Index


NAME

Top

Config::Trivial::Storable - Very simple tool for reading and writing very simple Storable configuration files

VERSION

Top

This documentation refers to Config::Trivial::Storable version 0.30

SYNOPSIS

Top

  use Config::Trivial::Storable;
  my $config = Config::Trivial::Storable->new(config_file => "path/to/my/config.conf");
  my $settings = $config->retrieve;
  print "Setting Colour is:\t", $settings->{'colour'};
  $settings->{'new-item'} = "New Setting";
  $settings->store;

DESCRIPTION

Top

Use this module when you want use "Yet Another" very simple, light weight configuration file reader. The module extends Config::Trivial by providing Storable Support. See those modules for more details.

SUBROUTINES/METHODS

Top

store

The store method outputs a Storable binary version of the configuration rather than a plain text version that the write version would.

There are two optional parameters that can be passed, a file name to use instead of the current one, and a reference of a hash to write out instead of the currently loaded one.

  $config->store(
    file_name => "/path/to/somewhere/else",
    configuration => $settings);

The method returns true on success. If the file already exists then it is backed up first. The store takes place using Storable's "lock_store" which uses Perl's flock. If the file cannot be written to then it will die.

Configuration data passed by this method is only written to file, it is not stored in the internal configuration object. To store data in the internal use the set_configuration data method. The option to pass a hash_ref in this method may be removed in future versions.

retrieve

This is the analog to read, only it reads data from a Storable binary.

  $config->retrieve;

If both Storable and traditional text configuration files are set then retrieve will use the Storable version in preference, but if the text version is newer then that will be used instead. Thus you can easily edit the text version and any code using this module will automatically switch to using it.

set_storable_file

If you want to explicitly set the file name of a storable file you may use this method. If you set a file name by both set_storable_file and set_config_file, then the retrieve method will "magically" decided which to use. The read method will ignore any storable settings.

CONFIG FORMAT

Top

About The Configuration File Format

This module extends Config::Trivial with optional support for using Storable binaries as a configuration file format, rather than plain text files.

The format of the text files is as with Config::Trivial and remains unchanged, as this module inherits from that one. The Storable format is offered so that modules can simple "retrieve" their configuration without the use of any particular configuration module.

This module extends Config::Trivial so that they can be used to quickly read configuration in one format and convert to another.

DEPENDENCIES

Top

At the moment the module only uses core modules, plus Config::Trivial The test suite optionally uses POD::Coverage, Test::Pod::Coverage, Test::Pod and IO::Warnings which will be skipped if you do not have them.

BUGS AND LIMITATIONS

Top

Patches very welcome... ;-)

MISC

Top

History

See Changes file.

EXPORT

Top

None.

AUTHOR

Top

Adam Trickett, <atrickett@cpan.org>

SEE ALSO

Top

perl, Config::Trivial, Storable.

LICENSE AND COPYRIGHT

Top


Config-Trivial-Storable documentation  | view source Contained in the Config-Trivial-Storable distribution.