Text::DHCPLeases(3)

NAME
Text::DHCPLeases - Parse DHCP leases file from ISC dhcpd.

SYNOPSIS
    use Text::DHCPLeases;

    my $leases = Text::DHCPLeases->new("/etc/dhcpd.leases");

    foreach my $obj ( $leases->get_objects ){
        print $obj->name;
        if ( $obj->binding_state eq 'active' ){
           ...
    }
    ...

DESCRIPTION
This module provides an object-oriented interface to ISC DHCPD leases files. The goal is to objectify all declarations, as defined by the ISC dhcpd package man pages.

This interface is useful for analyzing, reporting, converting lease files, or as a tool for other applications that need to import dhcpd lease data structures.

CLASS METHODS

  new - Class Constructor
  Arguments:
    Hash with the following keys:
    file  -  Leases file path
  Returns:
    Text::DHCPLeases object
  Examples:
    Text::DHCPLeases->new(file=>"/etc/dhcpd.leases");

INSTANCE METHODS

  get_objects - Get objects from leases file
  Arguments:
    Object attributes to match (optional)
  Returns:
    Array of Text::DHCPLeases::Lease objects,
    or iterator depending on context.
  Examples:
    my $it = $leases->get_objects(ip_address=>'192.168.0.1');
    while ( my $obj = $it->next ) ...

  print - Print all lease objects contents as a formatted string
  Arguments:
    None
  Returns:
    Formatted String
  Examples:
    print $leases->print;

BUGS AND LIMITATIONS
Correct parsing of leases files depends on changes made to the format of said files by the authors of the ISC DHCPD package. This module was tested against leases files generated by ISC DHCPD version 3.1.0. In addition, I do not have access to leases file with all possible declarations and statements, so parsing could be broken in some circumstances. Patches are welcome.

No bugs have been reported.

Please report any bugs or feature requests to "bug-Text-DHCPleases@rt.cpan.org", or through the web interface at <http://rt.cpan.org>.

AUTHOR
Carlos Vicente <cvicente@cpan.org>

LICENCE AND COPYRIGHT
Copyright (c) 2012, Carlos Vicente <cvicente@cpan.org>. All rights reserved.

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

DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.