Net::DNS::ZoneParse::Zone - A representation of a given zone.
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;
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.
$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:
The directory to use as working dir for the file. The current directory, if not given.
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".
The default time to live for the resource records.
if given, is the Net::DNS::ZoneParse object, this Zone is derived from
by default, the corresponding zonefile will be loaded on creating the new zone. If this dontload is true, the zone will start empty.
$zone->load()
Will open the corresspondig file and parse it, intializing the array of resource records
$zone->save();
will write back the contents of the zone to the corresponding filename
$zonetext = $zone->string();
string will return the contents of a zonefile representing the current state of the zone.
$zone->add($rr)
add can be used to add further resource records to the zone
$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.
$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.
$zone->delall();
Deletes all parsed resource records and deletes the corresponding zonefile from disk.
Net::DNS::ZoneParse
Benjamin Tietz <benjamin@micronet24.de>
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.
To install Net::DNS::ZoneParse, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::DNS::ZoneParse
CPAN shell
perl -MCPAN -e shell install Net::DNS::ZoneParse
For more information on module installation, please visit the detailed CPAN module installation guide.