NAME

YATT::Lite::XHF - Loader for XHF format

SYNOPSIS

require YATT::Lite::XHF;

my $parser1 = YATT::Lite::XHF->new(FH => \*STDIN);

# or
my $parser2 = YATT::Lite::XHF->new(filename => $filename);

# or
my $parser = YATT::Lite::XHF->new(string => <<'END');
foo: 1
bar: 2

foo{
wibble: wobble
}
bar[
- foo
- bar
- baz
]

END

# read() returns one set of parsed result by one paragraph, separated by \n\n+.
# In array context, you will get a flattened list of items in one paragraph.
# (It may usually be a list of key-value pairs, but you can write other types)
# In scalar context, you will get a hash struct.
while (my %hash = $parser->read) {
  print Dumper(\%hash), "\n";
}

{
  # You can use YATT::Lite::XHF as mixin for read_file_xhf() and parse_xhf()
  package MyPackage {
    use YATT::Lite::XHF;
    ...
  }
  # XXX: currently, both only reads first paragraph. This may be confusing.
  my %hash2 = MyPackage->read_file_xhf($filename);
  my %hash3 = MyPackage->parse_xhf($string);
}

DESCRIPTION

This is a parser/loader for Extended Header Fields format (XHF). For XHF definition, see YATT::Lite::XHF::Syntax.

METHODS

new(@OPTS)

configure(@OPTS)

read(@OPTS)

EXPORTED FUNCTIONS

->read_file_xhf($filename)

->parse_xhf($string)

OPTIONS

FH => $filehandle
filename => $filename
string => $xh_string
skip_comment => $bool
bytes => $bool

AUTHOR

"KOBAYASI, Hiroaki" <hkoba@cpan.org>

LICENSE

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