Config...:Dumper(3pm)
π
Config::Model::Dumper β the Config...:Dumper(3pm) page, but make it make sense
ok so bestie, this is a page from the User Contributed Perl Documentation section of the manual, and it's all about Config::Model::Dumper. Buckle up, it's actually slay.
β¨ NAME β¨
Config::Model::Dumper β serialize data of config tree π
π VERSION π
version 2.166 β yes, she's got a version number, we love a numbered queen π
π¦ SYNOPSIS π¦
use Config::Model ;
# 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',
},
},
],
) ;
my $inst = $model->instance(root_class_name => 'MyClass' );
my $root = $inst->config_root ;
# put some data in config tree the hard way
$root->fetch_element('foo')->store('yada') ;
$root->fetch_element('bar')->store('bla bla') ;
$root->fetch_element('baz')->fetch_with_id('en')->store('hello') ;
# put more data the easy way
my $steps = 'baz:fr=bonjour baz:hr="dobar dan"';
$root->load( steps => $steps ) ;
# dump only customized data
print $root->dump_tree;
like, that's the whole vibe right there. build a model, shove data in, dump it. periodt π
π DESCRIPTION π
So here's the tea: Config::Model::Node uses this module directly to serialize configuration data into a compact (but readable, because we're not monsters) string. π
She's got modes, and the default one is the standard mode β where literally only the customized values get dumped. Translation: only the stuff the user actually changed shows up. If you didn't touch it, she doesn't talk about it. iconic.
Every other mode that fetch in Config::Model::Value supports? Yeah, those work here too β so you can, for instance, get default values out of her. π
And the string she spits out? Config::Model::Loader can eat it right back up and store the data into a configuration tree. round trip, no cap. π₯
β οΈ heads up bestie: undefined values are skipped for list elements. So if a list element contains('a',undef,'b'), the dump is just gonna have'a','b'. theundefis not invited to the party. π
πΈ CONSTRUCTOR πΈ
π new
No parameter, babes. Zero. Nada. The constructor should be used only by Config::Model::Node β it's not for you, it's for her.
π§ Methods
π dump_tree
Returns a string containing a dump of the object tree with all the values. This string follows the convention that Config::Model::Loader defines.
And yes, that serialized string can be handed to Config::Model::Loader to store the data back into a configuration tree. we love a full circle moment π«Ά
Parameters are:
modeβ"full"dumps all configuration data, including default values. Every mode value fromfetchinConfig::Model::Valuecan be used here. By default though, the dump gives you only the data modified by the user (i.e."custom"data that differs from default or preset values). β¨nodeβ a reference to theConfig::Model::Nodeobject that's being dumped. All nodes and leaves attached to this node get dumped too. the whole squad comes along πskip_auto_write ( <backend_name> )β skips nodes that have a write capability matchingbackend_namein their model. CheckConfig::Model::BackendMgrfor the details.
You must use this option when you're using Dumper to write back configuration data. Here's why: when a configuration model has several backends (one at the tree root, and others in tree nodes), setting this option makes sure the "root" configuration file does not contain data that's already duplicated in the configuration file of other tree nodes. no duplicate content in this house π«
auto_vivifyβ scans and creates data for nodes elements even if no actual data was stored in them. This can be handy for trapping missing mandatory values. (default:0) πcheckβ checks the value before dumping. The valid checks are'yes','no'and'skip'. β
π AUTHOR π
Dominique Dumont, (ddumont at cpan dot org)
π SEE ALSO π
Config::Model, Config::Model::Node, Config::Model::Loader
π 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 a wrap, bestie π
this whole page ships with perl v5.42.3, dated 2026-07-23, and lives at Config...:Dumper(3pm) in the User Contributed Perl Documentation β go forth and dump responsibly π¦β¨
π¦ 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