The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::DNS::ZoneParse::Zone - A representation of a given zone.

SYNOPSIS

  use Net::DNS::ZoneParse::Zone;
  use Net::DNS::RR;

  my $zone = Net::DNS::ZoneParse::Zone->new({ filename => "db.example.com" });
  
  my $newrr = Net::DNS::RR::new({ ... });
  $zone->add($newrr);
  $zone->rr->[-1]->name eq $newrr->name;
  $zone->save;

DESCRIPTION

Net::DNS::ZoneParse::Zone is the representation of one zonefile, used by N::D::ZoneParse. It can be used to access and modify all information of this zone and write them back transperantly.

METHODS

new

        $zone = Net::DNS::ZoneParse::Zone->new("example.com" [, $param]);

returns a new Zone-object. The first parameter is the domain-name or origin of that zone, the optional second is a hash-reference of one or more of the followin:

path

The directory to use as working dir for the file. The current directory, if not given.

filename

The name of the file to read. If not given, "db." will prepended to the name of the zone; thus "db.example.com" would be used for "example.com".

ttl

The default time to live for the resource records.

parent

if given, is the Net::DNS::ZoneParse object, this Zone is derived from

dontload

by default, the corresponding zonefile will be loaded on creating the new zone. If this dontload is true, the zone will start empty.

load

        $zone->load()

Will open the corresspondig file and parse it, intializing the array of resource records

save

        $zone->save();

will write back the contents of the zone to the corresponding filename

string

        $zonetext = $zone->string();

string will return the contents of a zonefile representing the current state of the zone.

add

        $zone->add($rr)

add can be used to add further resource records to the zone

delete

        $zone->delete($rr)

deletes the given RR from the zone. If no RR is given, the zone will be purged. The RR can either be given as a Net::DNS::RR-object, in this case, the string representation of the record is compared to find the correct one. As an alternative a HASH-reference can be used, to filter for a set of RRs. In this case all keys of the hash must be found and equal in the RR.

replace

        $zone->replace($old, $new)

Replaces all RRs of the zone matching $old by the Net::DNS::RR-object given in $new. $old is handled in the same way as $rr in the delete-method. If $new is not given, replace behaves exactly like delete.

delall

        $zone->delall();

Deletes all parsed resource records and deletes the corresponding zonefile from disk.

SEE ALSO

Net::DNS::ZoneParse

AUTHOR

Benjamin Tietz <benjamin@micronet24.de>

COPYRIGHT

Copyright (C) 2010 by Benjamin Tietz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.