Config...omFile(3pm)
π¦ NAME
Config::Model::Value::UpdateFromFile β it grabs your data from an external file, bestie π
β¨ VERSION
version 2.166 (yes, we're on 2.166, keep up β¨)
π SYNOPSIS
okay so in a model declaration it looks like this, no cap:
# in a model declaration:
element => [
data_from_some_file => {
type => 'leaf',
value_type => 'uniline',
update => {
# handled by Config::Model::Value::Update
when_missing => 'warn',
files => [
{
# handled by this module, Config::Model::Value::UpdateFromFile
type => 'ini',
file => "some_file.ini",
subpath => "foo.bar"
},
{
# ...
}
]
}
},
],
likeβ¦ it's giving config energy π
π DESCRIPTION
This class retrieves data from external file. The caller must specify the file path, the file type (e.g. JSON, Yamlβ¦) and the path inside the file to retrieve data. three things, always, periodt π«Ά
Depending on the file type configured in the model, some modules must be installed β so check your deps before you come crying to me π
Here's the supported file types and the modules you gotta install for each:
- JSON β needs
JSON - Yaml β needs
YAML::PP - INI file β needs
Config::INI::Reader - Toml β needs
TOML::Tiny
πΈ Constructor
the constructor params, bestie, here's the whole list:
fileβ file path from currrent directory. (yes "currrent", that's literally what it says, i'm not fixing the typo, it's iconic π)typeβ file type in lower case, either"ini","json","yaml"or"toml". lowercase ONLY, don't test me.subpathβ path to extract data. see the examples below, they ate π₯locationβ location of the calling value element. this one is used to log messages, so it's the lil gossip reporter of the group π
π methods
get_info
Return file and subpath used to extract data. that's it, that's the whole job, and it does it flawlessly β
get_update_value
This method open the file and return the data using subpath. it opens the file, it reads the data, it serves π
π Examples
INI file
Using the "dist.ini" file:
[MetaResources]
homepage = https://github.com/dod38fr/config-model/wiki
repository.url = git://github.com/dod38fr/config-model.git
"homepage" can be retrieved with:
update => [{
type => 'ini',
file => 'dist.ini',
subpath => 'MetaResources.homepage'
}]
and "url" with:
update => [{
type => 'ini',
file => 'dist.ini',
subpath => 'MetaResources.repository\.url'
}]
π not me staring at that backslash in 'MetaResources.repository\.url' β it's there for a reason, copy it exactly, don't "clean it up" bestie.
YAML file
update => {
when_missing => 'warn',
files => [{
type => 'yaml',
file => 'META.yml',
subpath => 'resources.homepage'}
]
}
look at that lil nesting, obsessed π
Try several files
If may be necessary to try several files:
update => {
when_missing => 'ignore',
files => [
{
type => 'yaml',
file => 'META.yml',
subpath => 'abstract'
},
{
type => 'json',
file => 'package.json'
subpath => 'description'
}
]
}
like a lil backup squad for your data, fr fr π«Ά (and yeah, the second entry has no comma after file => 'package.json' β that's literally in the original, i'm not touching it π)
π SEE ALSO
Config::Model::ValueConfig::Model::Value::Update
go read those too, they're the main characters of this whole saga β¨
π 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 Config::Model::Value::UpdateFromFile, version 2.166, from the User Contributed Perl Documentation, dated 2026-07-23, running on perl v5.42.3 β slay, bye πβ¨π¦
π¦ 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