Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  MOOX::CONFIGFROMFILE (3)

.ds Aq ’


MooX::ConfigFromFile - Moo eXtension for initializing objects from config file



   package Role::Action;

   use Moo::Role;

   has operator => ( is => "ro" );

   package Action;

   use Moo;
   use MooX::ConfigFromFile; # imports the MooX::ConfigFromFile::Role

   with "Role::Action";

   sub operate { return say shift->operator; }

   package OtherAction;

   use Moo;

   with "Role::Action", "MooX::ConfigFromFile::Role";

   sub operate { return warn shift->operator; }

   package QuiteOtherOne;

   use Moo;

   # consumes the MooX::ConfigFromFile::Role but load config only once
   use MooX::ConfigFromFile config_singleton => 1;

   with "Role::Action";

   sub _build_config_prefix { "die" }

   sub operate { return die shift->operator; }

   package main;

   my $action = Action->new(); # tries to find a config file in config_dirs and loads it
   my $other = OtherAction->new( config_prefix => "warn" ); # use another config file
   my $quite_o = QuiteOtherOne->new(); # quite another way to have an individual config file


This module is intended to easy load initialization values for attributes on object construction from an appropriate config file. The building is done in MooX::ConfigFromFile::Role - using MooX::ConfigFromFile ensures the role is applied.

For easier usage, with 0.004, several options can be passed via use resulting in default initializers for appropriate role attributes:
config_prefix Default for config_prefix in MooX::ConfigFromFile::Role.
config_prefix_map_separator Default for config_prefix_map_separator in MooX::ConfigFromFile::Role.
config_extensions Default for config_extensions in MooX::ConfigFromFile::Role.
config_dirs Default for config_dirs in MooX::ConfigFromFile::Role. Same warning regarding modifying this attribute applies here: Possible, but use with caution!
config_files Default for config_files in MooX::ConfigFromFile::Role.

Reasonable when you want exactly one config file in development mode. For production code it is highly recommended to override the builder.

config_singleton Flag adding a wrapper around the builder of loaded_config in MooX::ConfigFromFile::Role to ensure a config is loaded only once per class. The per class restriction results from applicable modifiers per class (and singletons are per class).
config_identifier Default for config_identifier in MooX::File::ConfigDir.


Jens Rehsack, <rehsack at>


Please report any bugs or feature requests to bug-moox-configfromfile at, or through the web interface at <>. I will be notified, and then you’ll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc MooX::ConfigFromFile

You can also look for information at:
o RT: CPAN’s request tracker (report bugs here)


o AnnoCPAN: Annotated CPAN documentation


o CPAN Ratings


o Search CPAN




Copyright 2013-2015 Jens Rehsack.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <> for more information.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 MOOX::CONFIGFROMFILE (3) 2015-04-27

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.