Datafile::Simple - README

Datafile::Simple is a lightweight pure-Perl distribution containing two complementary modules for handling common data files:

Both modules share the same design philosophy:

Perl License

Installation

perl Makefile.PL
make
make test
make install

Modules

Datafile::Array

Handles reading and writing delimited data files with optional CSV quoting, headers, and prefix lines.

SYNOPSIS

use Datafile::Array qw(readarray writearray parse_csv_line);

my @records;
my @fields;

my ($count, $msgs) = readarray('data.txt', \@records, \@fields, {
    delimiter    => ';',
    csvquotes    => 1,        # full CSV support with multi-line
    has_headers  => 1,
    prefix       => 1,        # H/R prefix mode
    trim_values  => 1,
    verbose      => 1,
});

writearray('data.txt', \@records, \@fields, {
    header  => 1,
    prefix  => 1,
    backup  => 1,
    comment => 'Exported on ' . scalar localtime,
});

# Standalone CSV parsing
my @parts = parse_csv_line('a,"b,c","d""e"', ',');

FUNCTIONS

KEY OPTIONS

Datafile::Hash

Handles flat key-value files and full INI-style files with multi-level sections.

SYNOPSIS

use Datafile::Hash qw(readhash writehash);

my %config;

# INI with nested sections
readhash('config.ini', \%config, {
    delimiter => '=',      # triggers INI mode
    group     => 2,        # nested hashes (default)
});

# $config{database}{host} = 'localhost'

# Flat file
readhash('settings.txt', \%config, {
    delimiter => '=',
    group     => 0,        # ignore sections, flat hash
});

writehash('config.ini', \%config, {
    backup  => 1,
    comment => ['Auto-generated', scalar localtime],
});

FUNCTIONS

KEY OPTIONS

INI mode features:

Common Features

Both modules:

License

This module is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

See the official Perl licensing terms: https://dev.perl.org/licenses/