The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Config::Frontend - Configuration module with flexible backends

SYNOPSIS

 use Config::Frontend;
 use Config::Frontend::String;
 
 open my $in,"<conf.cfg";
 my $string=<$in>;
 close $in;

 my $cfg=new Conf(new Config::Frontend::String(\$string))

 print $cfg->get("config item 1");
 $cfg->set("config item 1","Hi There!");

 $cfg->set("cfg2","config 2");

 $cfg->del("config item 1");

 open my $out,">conf.cfg";
 print $out $string;
 close $out;

ABSTRACT

This module can be used to put configuration items in. It's build up by using a backend and an interface. The interface is through the Config::Frontend module. A Config::Frontend object is instantiated with a backend.

DESCRIPTION

new(backend) --> Conf

Should be called with a pre-instantiated backend. Returns a Config::Frontend object.

set(var,val) --> void

Sets a variable with value val in the backend.

get(var [, default]) --> string

Returns the value for var as stored in the backend. Returns undef, if var does not exist in the backend and default has not been given. Otherwise, returns default, if var does not exist in the backend.

del(var) --> void

Deletes a variable from the backend.

variables() --> list of stored variables

Returns a list all variables stored in the backen.

cache(cache_on) --> void

If cache_on = true, this will turn on caching for the get() method. If caching is on, the get() method will only go to the backend if a variable does not exist in it's cache. The set() function will delete a variable from cache if it is updated. The del() function will delete a variable from cache.

clear_cache() --> void

Clears the cache.

SEE ALSO

Config::Backend::String, Config::Backend::SQL, Config::Backend::File, Config::Backend::INI.

AUTHOR

Hans Oesterholt-Dijkema, <oesterhol@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2004 by Hans Oesterholt-Dijkema

This library is free software; you can redistribute it and/or modify it under Artistic License.