Config...rlFile(3pm)
π Config::Model::Backend::PerlFile π
okay bestie, so this is Config::Model::Backend::PerlFile(3pm) β User Contributed Perl Documentation, and it is literally the moment. it does one thing and it does it gorgeously: read and write your config as a Perl data structure. π
β¨ NAME β¨
Config::Model::Backend::PerlFile β Read and write config as a Perl data structure. that's it. that's the gig. π
πΈ VERSION πΈ
version 2.166. periodt.
π¦ SYNOPSIS π¦
not me giving you the whole recipe, no gatekeeping, we share β¨
use Config::Model ;
use Data::Dumper ;
# define configuration tree object
my $model = Config::Model->new ;
$model ->create_config_class (
name => "MyClass",
element => [
[qw/foo bar/] => {
type => 'leaf',
value_type => 'string'
},
baz => {
type => 'hash',
index_type => 'string' ,
cargo => {
type => 'leaf',
value_type => 'string',
},
},
],
rw_config => {
backend => 'perl_file' ,
config_dir => '/tmp',
file => 'foo.pl',
auto_create => 1,
},
) ;
my $inst = $model->instance(root_class_name => 'MyClass' );
my $root = $inst->config_root ;
my $steps = 'foo=yada bar="bla bla" baz:en=hello
baz:fr=bonjour baz:hr="dobar dan"';
$root->load( steps => $steps ) ;
$inst->write_back ;
and then β the glow up β now, "/tmp/foo.pl" contains:
{
bar => 'bla bla',
baz => {
en => 'hello',
fr => 'bonjour',
hr => 'dobar dan'
},
foo => 'yada'
}
ate. no crumbs. π
π DESCRIPTION π
Config::Model calls this module directly to read or write the contents of a configuration tree that's written with Perl syntax inside a Config::Model configuration tree. it's the translator between your cute tree and a real file, iykyk π«Ά
Note: heads up, two things, both important, don't skip:
- Undefined values get skipped for list elements. like, if a list element holds
('a',undef,'b'), the data structure you get just contains'a','b'. theundef? ghosted. π» - The Perl file is not created (and may honestly get deleted π) when there's no data to write. it's giving "if I have nothing to say I stay home".
π backend parameter π
config_dir
A mandoatory parameter β you have to pass it, bestie, no exceptions β and it says where the Perl configuration file lives. π
π CONSTRUCTOR π
new
Inherited from Config::Model::Backend::Any. you don't call it yourself, it gets called by Config::Model::BackendMgr. it's the main character that just shows up. β¨
read
Out of all the parameters handed to this read call-back, only ifile_path actually gets used. and that parameter has to be an IO::File object that's already opened for read. π
It can also be undef β in which case read returns 0.
When a file is read, read returns 1.
write
Out of all the parameters passed to this write call-back, only file_path is used, and it must be a Path::Tiny object. βοΈ
write returns 1.
π AUTHOR π
Dominique Dumont, (ddumont at cpan dot org)
β SEE ALSO β
Config::Model, Config::Model::BackendMgr, Config::Model::Backend::Any,
π AUTHOR π
Dominique Dumont
π₯ COPYRIGHT AND LICENSE π₯
This software is Copyright (c) 2005-2022 by Dominique Dumont.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
and that's the whole page, bestie π§ this was perl v5.42.3, dated 2026-07-23 β go forth and configure, you're gonna slay π πΈπ¦
π¦ where this page comes from
- ubuntu stonking: libconfig-model-perl 2.166-1 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms