NAME

Text::Unpack::Auto - automatically generate unpack strings from fixed-width text

SYNOPSIS

use Text::Unpack::Auto;

my @rows = auto_unpack(@lines);
for my $row (@rows) {
    say join ', ', @$row;
}

my $fmt = guess_unpack(@lines);

my @rows = auto_unpack({ minimum_gap => 3 }, @lines);

DESCRIPTION

Detects fixed-width column boundaries in plain text and unpacks lines into fields.

FUNCTIONS

Text::Unpack::Auto exports "guess_unpack" and "auto_unpack" by default.

guess_unpack

my $fmt = guess_unpack(@lines);
my $fmt = guess_unpack(\%opts, @lines);

Returns an unpack template string derived from the column boundaries detected in @lines.

auto_unpack

my @rows = auto_unpack(@lines);
my @rows = auto_unpack(\%opts, @lines);

Unpacks each line into an arrayref of trimmed fields. Returns one arrayref per input line.

Options

minimum_gap
minimum_gap => 3

Gaps narrower than this are treated as part of the surrounding column rather than as column separators.

AUTHOR

Simone Cesano

COPYRIGHT AND LICENSE

Copyright (C) 2026 Simone Cesano

This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.