Config...CdsFile(3pm)

πŸ’– Config::Model::Backend::CdsFile πŸ’–

okay bestie, welcome to the Config...CdsFile(3pm) page β€” this is one of the User Contributed Perl Documentation girlies, and she's here to spill all the tea about reading and writing config as a Cds data structure. sit down, get cozy, we're doing this πŸ’…


🌸 NAME 🌸

Config::Model::Backend::CdsFile β€” bestie, this one reads and writes your config as a Cds data structure. iconic behavior, honestly.


✨ VERSION ✨

version 2.166 πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe, no cap:

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 => 'cds_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 now β€” plot twist β€” "/tmp/foo.pl" contains:

{
  bar => 'bla bla',
  baz => {
    en => 'hello',
    fr => 'bonjour',
    hr => 'dobar dan'
  },
  foo => 'yada'
}

ate. no crumbs. periodt πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

so the way that Config::Model uses this module directly to read or write the content of a configuration tree β€” and that tree is written with Cds syntax, living inside a Config::Model configuration tree. that's the whole job, and she does it gorgeously ✨

Note: (important, bestie, don't skip this 🫢)

  • Undefined values are skipped for list element. like, if a list element contains ('a',undef,'b'), then the data structure contains 'a','b'. the undef just ✨ vanishes ✨.
  • Cds file is not created (and may be deleted) when no data is to be written. so if there's nothing to say, the file simply does not exist. she's mysterious like that πŸ’€

🌈 backend parameter 🌈

πŸ’œ config_dir πŸ’œ

Mandatory parameter to specify where is the Cds configuration file. you literally have to give her this one, okay? it's required, no skipping πŸ”₯


🧚 CONSTRUCTOR 🧚

🌸 new 🌸

Inherited from Config::Model::Backend::Any. The constructor is called by Config::Model::BackendMgr. so yeah, she doesn't roll solo β€” she gets summoned by the BackendMgr πŸ’«

πŸ’– read πŸ’–

Of all parameters passed to this read call-back, only file_path is used. literally just file_path, everything else is giving background character energy πŸ™ˆ

It can also be undef. In which case read returns 0. no file, no vibes, returns 0, bye.

When a file is read, read returns 1. slay πŸŽ€

πŸ¦‹ write πŸ¦‹

Of all parameters passed to this write call-back, only file_path is used. again with the lone file_path β€” she's loyal, ngl.

write returns 1. that's it, that's the whole function. short and iconic πŸ‘‘


πŸ’œ AUTHOR πŸ’œ

Dominique Dumont, (ddumont at cpan dot org)


πŸ”₯ SEE ALSO πŸ”₯

Config::Model, Config::Model::BackendMgr, Config::Model::Backend::Any,

(the comma at the end is canon, iykyk 🫢)


πŸŽ€ AUTHOR πŸŽ€

Dominique Dumont

(yes bestie, AUTHOR appears twice. we don't question the layout decisions, we respect them ✨)


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 on 2026-07-23, filed under Config...CdsFile(3pm) β€” you're gonna do amazing with it, go read some config files and slay πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from