Config...Update(3pm)

πŸ“¦
version 2.166 Β· 2 versions
, in ubuntu stonking

πŸ’– Config::Model::Value::Update β€” bestie edition ✨

okay so real talk, this is a page from the User Contributed Perl Documentation, and the manual name is Config...Update(3pm) (the full vibe is Config::Model::Value::Update, iykyk πŸ’…). It's a tiny module with a huge job, and I'm gonna walk you through it like we're texting at 2am. grab a snack πŸ“


✨ VERSION ✨

version 2.166 β€” that's the version, periodt. πŸŽ€


🌈 SYNOPSIS 🌈

so like, here's how it looks when you're declaring it inside a model. bestie, this is verbatim, don't touch a single character:

    # in a model declaration:
    element => [
        data_from_some_file => {
            type => 'leaf',
            value_type => 'uniline',
            update => {
                # handled by this module, Config::Model::Value::Update
                when_missing => 'warn',
                files => [
                    {
                        # handled by Config::Model::Value::UpdateFromFile
                        type => 'ini',
                        file => "some_file.ini",
                        subpath => "foo.bar"
                    },
                    {
                        # ...
                    }
                ]
            }
        },
    ],

see how the update block is ours (Config::Model::Value::Update) but each individual file entry inside files gets handed off to Config::Model::Value::UpdateFromFile? splitting the work, iconic behavior honestly πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

This class retrieves data from external files. For each file, the caller must specify:

  • the file path πŸ—‚οΈ
  • the file type (e.g. JSON, Yaml...) πŸ“„
  • the path inside the file to retrieve data πŸ”

three things. no more, no less, no cap.


🌸 Constructor 🌸

Constructor parameters are, and I quote (not really, I'm vibing, but the facts stay):

  • files β€” Configuration data to build an array of Config::Model::Value::UpdateFromFile objects. it's giving "build the whole squad" πŸ’ž
  • when_missing β€” Behavior when no data is found in any file. Can be "ignore", "warn" or "die". choose your fighter βš”οΈ (yes, die is literally one of the options, it's dramatic like that πŸ’€)
  • location β€” location of the calling value element. This is used to log messages. πŸ“ so when something goes wrong, the logs know where it went wrong. main character energy for error reporting.

🧚 methods 🧚

πŸŽ€ get_info

Return all files and subpaths used to extract data. that's it, that's the whole function. she's simple, she's efficient, she slays ✨

πŸ’œ get_update_value

Try to get data from the external files. The files are tried in the same order as the "files" parameter. Data is returned at the first successful try. 🏁

If no data can be found β€” either if all files are missing or all subpath do not yield data β€” this function either returns, warns or die, depending on the value of the "when_missing" parameter. so it's basically doing a vibe check on your when_missing setting and reacting accordingly 😭

lowkey important: this one does NOT come with a chill mode. if you told it die, it WILL die. respect the setting bestie πŸ™

🌟 Examples 🌟

a whole example, verbatim, so you can copy-paste and feel something:

    update => {
      when_missing => 'ignore',
      files => [
        {
           type => 'yaml',
           file => 'META.yml',
           subpath => 'abstract'
        },
        {
           type => 'json',
           file => 'package.json'
           subpath => 'description'
        }
      ]
    }

here it's trying META.yml first (yaml, pulling out abstract), then falling back to package.json (json, pulling out description). first one that hits wins. obsessed with the fallback energy 🫢


πŸ‘€ SEE ALSO πŸ‘€

  • Config::Model::Value
  • Config::Model::Value::UpdateFromFile

go read these too, they're the supporting cast and honestly they ate πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

Dominique Dumont β€” author extraordinaire, we stan 🌈


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 beauty shipped with perl v5.42.3, dated 2026-07-23 (yes I said 2026, that's what it says, don't come for me πŸ™ˆ). now go forth and pull data from external files like the absolute icon you are πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from