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( 'named.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 introduced by the $INCLUDE directive. Zone
22 file syntax is defined by RFC1035.
23
24 A program may 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( 'filename', ['example.com'] );
37
38 $handle = new IO::File( 'filename', '<:encoding(ISO8859-7)' );
39 $zonefile = new Net::DNS::ZoneFile( $handle, ['example.com'] );
40
41 The new() constructor returns a Net::DNS::ZoneFile object which
42 represents the zone file specified in the argument list.
43
44 The specified file or file handle is open for reading and closed when
45 exhausted or all references to the ZoneFile object cease to exist.
46
47 The optional second argument specifies $ORIGIN for the zone file.
48
49 Character encoding is specified indirectly by creating a file handle
50 with the desired encoding layer, which is then passed as an argument to
51 new(). The specified encoding is propagated to files introduced by
52 $include directives.
53
54 read
55 $rr = $zonefile->read;
56 @rr = $zonefile->read;
57
58 When invoked in scalar context, read() returns a Net::DNS::RR object
59 representing the next resource record encountered in the zone file, or
60 undefined if end of data has been reached.
61
62 When invoked in list context, read() returns the list of Net::DNS::RR
63 objects in the order that they appear in the zone file.
64
65 Comments and blank lines are silently disregarded.
66
67 $INCLUDE, $ORIGIN, $TTL and $GENERATE directives are processed
68 transparently.
69
70 name
71 $filename = $zonefile->name;
72
73 Returns the name of the current zone file. Embedded $INCLUDE
74 directives will cause this to differ from the filename argument
75 supplied when the object was created.
76
77 line
78 $line = $zonefile->line;
79
80 Returns the number of the last line read from the current zone file.
81
82 origin
83 $origin = $zonefile->origin;
84
85 Returns the fully qualified name of the current origin within the zone
86 file.
87
88 ttl
89 $ttl = $zonefile->ttl;
90
91 Returns the default TTL as specified by the $TTL directive.
92
94 Applications which depended on the defunct Net::DNS::ZoneFile 1.04 CPAN
95 distribution will continue to operate with minimal change using the
96 compatibility interface described below.
97
98 use Net::DNS::ZoneFile;
99
100 $listref = Net::DNS::ZoneFile->read( $filename );
101 $listref = Net::DNS::ZoneFile->read( $filename, $include_dir );
102
103 $listref = Net::DNS::ZoneFile->readfh( $handle, $include_dir );
104
105 $listref = Net::DNS::ZoneFile->parse( $string );
106 $listref = Net::DNS::ZoneFile->parse( $string, $include_dir );
107 $listref = Net::DNS::ZoneFile->parse( \$string, $include_dir );
108
109 $_->print for @$listref;
110
111 The optional second argument specifies the default path for filenames.
112 The current working directory is used by default.
113
114 Although not available in the original implementation, the RR list can
115 be obtained directly by calling any of these methods in list context.
116
117 @rr = Net::DNS::ZoneFile->read( $filename, $include_dir );
118
119 read
120 $listref = Net::DNS::ZoneFile->read( $filename, $include_dir );
121 @rr = Net::DNS::ZoneFile->read( $filename, $include_dir );
122
123 read() parses the specified zone file and returns a reference to the
124 list of Net::DNS::RR objects representing the RRs in the file. The
125 return value is undefined if the zone data can not be parsed.
126
127 When called in list context, the partial result is returned if an error
128 is encountered by the parser.
129
130 readfh
131 $listref = Net::DNS::ZoneFile->readfh( $handle, $include_dir );
132
133 readfh() parses data from the specified file handle and returns a
134 reference to the list of Net::DNS::RR objects representing the RRs in
135 the file.
136
137 parse
138 $listref = Net::DNS::ZoneFile->parse( $string, $include_dir );
139 $listref = Net::DNS::ZoneFile->parse( \$string, $include_dir );
140
141 parse() interprets the zone file text in the argument string and
142 returns a reference to the list of Net::DNS::RR objects representing
143 the RRs.
144
146 This package is designed as an improved and compatible replacement for
147 Net::DNS::ZoneFile 1.04 which was created by Luis Munoz in 2002 as a
148 separate CPAN module.
149
150 The present implementation is the result of an agreement to merge our
151 two different approaches into one package integrated into Net::DNS.
152 The contribution of Luis Munoz is gratefully acknowledged.
153
154 Thanks are also due to Willem Toorop for his constructive criticism of
155 the initial version and invaluable assistance during testing.
156
158 Copyright (c)2011-2012 Dick Franks.
159
160 All rights reserved.
161
163 Permission to use, copy, modify, and distribute this software and its
164 documentation for any purpose and without fee is hereby granted,
165 provided that the above copyright notice appear in all copies and that
166 both that copyright notice and this permission notice appear in
167 supporting documentation, and that the name of the author not be used
168 in advertising or publicity pertaining to distribution of the software
169 without specific prior written permission.
170
171 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
172 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
173 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
174 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
175 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
176 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
177 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
178
180 perl, Net::DNS, Net::DNS::RR, RFC1035 Section 5.1, RFC2308, BIND 9
181 Administrator Reference Manual
182
183
184
185perl v5.26.3 2018-02-09 Net::DNS::ZoneFile(3)