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'. the undef is 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 from fetch in Config::Model::Value can 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 the Config::Model::Node object 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 matching backend_name in their model. Check Config::Model::BackendMgr for 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

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