The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Text::LBSV - Labeled Bell Separated Value manipulator

SYNOPSIS

use Text::LBSV;
my $p = Text::LBSV->new;
my $hash = $p->parse_line("hoge:foo\abar:baz\n");
is $hash->{hoge}, 'foo';
is $hash->{bar},  'baz';

my $data = $p->parse_file('./t/test.lbsv'); # or parse_file_utf8
is $data->[0]->{hoge}, 'foo';
is $data->[0]->{bar}, 'baz';

# Iterator interface
my $it = $p->parse_file_iter('./t/test.lbsv'); # or parse_file_iter_utf8
while ($it->has_next) {
    my $hash = $it->next;
    ...
}
$it->end;

# Only want certain fields?
my $p = Text::LBSV->new;
$p->want_fields('hoge');
$p->parse_line("hoge:foo\abar:baz\n");

# Vise versa
my $p = Text::LBSV->new;
$p->ignore_fields('hoge');
$p->parse_line("hoge:foo\abar:baz\n");

my $lbsv = Text::LBSV->new(
  hoge => 'foo',
  bar  => 'baz',
);
is $lbsv->to_s, "hoge:foo\abar:baz";

DESCRIPTION

Labeled Bell-separated Values (LBSV) format is a variant of Bell-separated Values (BSV). Each record in a LBSV file is represented as a single line. Each field is separated by BELL and has a label and a value. The label and the value have been separated by ':'.

cf: http://lbsv.org/

This format is useful for log files, especially HTTP access_log.

This module provides a simple way to process LBSV-based string and files, which converts Key-Value pair(s) of LBSV to Perl's hash reference(s).

AUTHOR

HIROSE Masaaki <hirose31@gmail.com> Naoya Ito <i.naoya@gmail.com>

LICENSE

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