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

Parse::DebControl - Easy OO parsing of debian control-like files

SYNOPSIS

        use Parse::DebControl

        $parser = new Parse::DebControl;

        $data = $parser->parse_mem($control_data);
        $data = $parser->parse_file('./debian/control');

        $parser->DEBUG();

DESCRIPTION

        Parse::DebControl is an easy OO way to parse debian control files and 
        other colon separated key-value pairs. It's specifically designed
        to handle the format used in Debian control files, template files, and
        the cache files used by dpkg.

        For basic format information see:
        http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-controlsyntax

        This module does not actually do any intelligence with the file content
        (because there are a lot of files in this format), but merely handles
        the format. It can handle simple control files, or files hundreds of lines 
        long efficiently and easily.

Class Methods

  • new()

  • new($debug)

    Returns a new Parse::DebControl object. If a true parameter $debug is passed in, it turns on debugging, similar to a call to DEBUG() (see below);

  • parse_file($control_filename)

    Takes a scalar containing formatted data. Will parse as much as it can, warning (if DEBUGing is turned on) on parsing errors.

    Returns an array of hashes, containing the data in the control file, split up by stanza. Stanzas are deliniated by newlines, and multi-line fields are expressed as such post-parsing. Single periods are treated as special extra newline deliniators, per convention.

  • parse_mem($control_data)

    Similar to parse_file, except takes data as a scalar. Returns the same array of hashrefs;

  • DEBUG()

    Turns on debugging. Calling it with no paramater or a true parameter turns on verbose warn()ings. Calling it with a false parameter turns it off. It is useful for nailing down any format or internal problems.

CHANGES

  • Version 1.0 - April 23rd, 2003

    This is the initial public release for CPAN, so everything is new.

BUGS

None that I know of. Please report any to jaybonci@cpan.org

TODO

Tie::IxHash support
Control file writing (as compared to writing)
Case-insensitive hash construction

These items will be implemented as as an options hash to the parsing functions

COPYRIGHT

Parse::DebControl is copyright 2003 Jay Bonci <jaybonci@cpan.org>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.