1Net::DNS::ZoneFile(3) User Contributed Perl DocumentationNet::DNS::ZoneFile(3)
2
3
4
6 Net::DNS::ZoneFile - DNS zone file
7
9 use Net::DNS::ZoneFile;
10
11 $zonefile = new Net::DNS::ZoneFile( 'db.example' );
12
13 while ( $rr = $zonefile->read ) {
14 $rr->print;
15 }
16
17 @zone = $zonefile->read;
18
20 Each Net::DNS::ZoneFile object instance represents a zone file together
21 with any subordinate files nominated using $INCLUDE directives. Zone
22 file syntax is defined by RFC1035.
23
24 A program can have multiple zone file objects, each maintaining its own
25 independent parser state information.
26
27 The parser supports both the $TTL directive defined by RFC2308 and the
28 BIND $GENERATE syntax extension.
29
30 All RRs in a zone file must have the same class, which may be specified
31 for the first RR encountered and is then propagated automatically to
32 all subsequent records.
33
35 new
36 $zonefile = new Net::DNS::ZoneFile( 'db.example', ['example.com'] );
37
38 Returns a Net::DNS::ZoneFile object which represents the zone file
39 specified in the argument list.
40
41 The file is opened for reading and remains open until exhausted or all
42 references to the ZoneFile object cease to exist.
43
44 The optional second argument specifies $ORIGIN for the zone file.
45
46 read
47 $rr = $zonefile->read;
48
49 When invoked in scalar context, returns the next RR encountered in the
50 zone file, or undefined if end of data has been reached.
51
52 Comments and blank lines are silently disregarded.
53
54 $INCLUDE, $ORIGIN, $TTL and $GENERATE directives are processed
55 transparently.
56
57 @rr = $zonefile->read;
58
59 When invoked in list context, returns the list of all RR objects in the
60 zone file.
61
62 name
63 $filename = $zonefile->name;
64
65 Returns the name of the zone file from which RRs will be read.
66 $INCLUDE directives will cause this to differ from the filename
67 argument supplied when the object was created.
68
69 line
70 $line = $zonefile->line;
71
72 Returns the line number of the last non-continuation line encountered
73 in the current zone file.
74
75 origin
76 $origin = $zonefile->origin;
77
78 Returns the fully qualified name of the current origin within the zone
79 file.
80
81 ttl
82 $ttl = $zonefile->ttl;
83
84 Returns the default TTL as specified by the $TTL directive.
85
87 Applications which depended on the Net::DNS::ZoneFile 1.04 package will
88 continue to operate with minimal change using compatibility interface
89 described below.
90
91 use Net::DNS::ZoneFile;
92
93 $listref = Net::DNS::ZoneFile->read( $filename, $include_dir );
94
95 $listref = Net::DNS::ZoneFile->readfh( $handle, $include_dir );
96
97 $listref = Net::DNS::ZoneFile->parse( $string, $include_dir );
98 $listref = Net::DNS::ZoneFile->parse( \$string, $include_dir );
99
100 $_->print for @$listref;
101
102 The optional second argument specifies the default path for filenames.
103 The current working directory is used by default.
104
105 Although not available in the original implementation, the RR list can
106 be obtained directly by calling in list context.
107
108 @rr = Net::DNS::ZoneFile->read( $filename, $include_dir );
109
110 read
111 $listref = Net::DNS::ZoneFile->read( $filename, $include_dir );
112
113 read() parses the specified zone file and returns a reference to the
114 list of Net::DNS::RR objects representing the RRs in the file. The
115 return value is undefined if the zone data can not be parsed.
116
117 readfh
118 $listref = Net::DNS::ZoneFile->readfh( $handle, $include_dir );
119
120 read() parses data from the specified file handle and returns a
121 reference to the list of Net::DNS::RR objects representing the RRs in
122 the file. The return value is undefined if the zone data can not be
123 parsed.
124
125 parse
126 $listref = Net::DNS::ZoneFile->parse( $string, $include_dir );
127 $listref = Net::DNS::ZoneFile->parse( \$string, $include_dir );
128
129 parse() interprets the argument string and returns a reference to the
130 list of Net::DNS::RR objects representing the RRs. The return value is
131 undefined if the zone data can not be parsed.
132
134 This package is designed as an improved and compatible replacement for
135 Net::DNS::ZoneFile 1.04 which was created by Luis Munoz in 2002 as a
136 separate CPAN module.
137
138 The present implementation is the result of an agreement to merge our
139 two different approaches into one package integrated into Net::DNS.
140 The contribution of Luis Munoz is gratefully acknowledged.
141
142 Thanks are also due to Willem Toorop for his constructive criticism of
143 the initial version and invaluable assistance during testing.
144
146 Copyright (c)2011-2012 Dick Franks
147
148 All rights reserved.
149
150 This program is free software; you may redistribute it and/or modify it
151 under the same terms as Perl itself.
152
154 perl, Net::DNS, Net::DNS::Domain, Net::DNS::RR, RFC1035 Section 5.1,
155 RFC2308, BIND 9 Administrator Reference Manual
156
157
158
159perl v5.16.3 2012-12-28 Net::DNS::ZoneFile(3)