NAME

Math::Formula::Config::INI - load/save formulas to file as INI

INHERITANCE

Math::Formula::Config::INI
  is a Math::Formula::Config

SYNOPSIS

my $context = Math::Formula::Content->new(name => 'test');
my $config  = Math::Formula::Config::INI->new(directory => $dir);

$config->save($context);
my $context = $config->load('test');

DESCRIPTION

Save and load a Math::Formula::Context to INI files. The INI file is not too complex.

You need to have installed Config::INI. That module is not in the dependencies of this packages, because we do not want to add complications to the main code.

Extends "DESCRIPTION" in Math::Formula::Config.

METHODS

Extends "METHODS" in Math::Formula::Config.

Constructors

Extends "Constructors" in Math::Formula::Config.

$class->new(%options)

Inherited, see "Constructors" in Math::Formula::Config

Attributes

Extends "Attributes" in Math::Formula::Config.

$obj->directory()

Inherited, see "Attributes" in Math::Formula::Config

$obj->path_for($file)

Inherited, see "Attributes" in Math::Formula::Config

Actions

Extends "Actions" in Math::Formula::Config.

$obj->load($name, %options)

Load a Math::Formula::Context for an INI file. Improves base, see "Actions" in Math::Formula::Config

-Option  --Default
 filename  <directory/$name.ini>
filename => FILENAME
$obj->save($context, %options)

Serialize the $context to INI files, as storage or to be edited by hand. This is a useful method when default configuration templates need to be generated. Improves base, see "Actions" in Math::Formula::Config

-Option  --Default
 filename  $context->name .ini
filename => STRING

Save under a different filename than derived from the name of the context.

DETAILS

According to Wikipedia, INI files only support strings and numbers. To stay as close as possible to that description, everything else is put between double quotes (also the booleans).

Only the quoted data may contain attributes.

. Example

name    = test
version = 1
created = "2023-02-26T20:07:54+0000"
updated = "2023-02-26T20:07:54+0000"
mf_version = 0

[formulas]
expr2 = "\"abc\".size + 3k"; returns='MF::INTEGER'
fakes = "false"
dinertime = "18:05:07"
expr1 = "1 + 2 * 3"
string = abc
some_truth = "true"

DIAGNOSTICS

Error: Save directory '$dir' does not exist

Error: Save directory required

Warning: cannot (yet) save CODE, skipped '$name'

SEE ALSO

This module is part of Math-Formula version 0.18, built on August 19, 2025. Website: http://perl.overmeer.net/CPAN/

LICENSE

For contributors see file ChangeLog.

This software is copyright (c) 2023-2025 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.