{
    "mode": "perldoc",
    "parameter": "Net::DNS::ZoneFile",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ADNS%3A%3AZoneFile/json",
    "generated": "2026-07-05T13:42:06Z",
    "synopsis": "use Net::DNS::ZoneFile;\n$zonefile = Net::DNS::ZoneFile->new( 'named.example' );\nwhile ( $rr = $zonefile->read ) {\n$rr->print;\n}\n@zone = $zonefile->read;",
    "sections": {
        "NAME": {
            "content": "Net::DNS::ZoneFile - DNS zone file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Net::DNS::ZoneFile;\n\n$zonefile = Net::DNS::ZoneFile->new( 'named.example' );\n\nwhile ( $rr = $zonefile->read ) {\n$rr->print;\n}\n\n@zone = $zonefile->read;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Each Net::DNS::ZoneFile object instance represents a zone file together with any subordinate\nfiles introduced by the $INCLUDE directive. Zone file syntax is defined by RFC1035.\n\nA program may have multiple zone file objects, each maintaining its own independent parser state\ninformation.\n\nThe parser supports both the $TTL directive defined by RFC2308 and the BIND $GENERATE syntax\nextension.\n\nAll RRs in a zone file must have the same class, which may be specified for the first RR\nencountered and is then propagated automatically to all subsequent records.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new\n$zonefile = Net::DNS::ZoneFile->new( 'filename', ['example.com'] );\n\n$handle   = IO::File->new( 'filename', '<:encoding(ISO8859-7)' );\n$zonefile = Net::DNS::ZoneFile->new( $handle, ['example.com'] );\n\nThe new() constructor returns a Net::DNS::ZoneFile object which represents the zone file\nspecified in the argument list.\n\nThe specified file or file handle is open for reading and closed when exhausted or all\nreferences to the ZoneFile object cease to exist.\n\nThe optional second argument specifies $ORIGIN for the zone file.\n\nZone files are presumed to be UTF-8 encoded where that is supported.\n\nAlternative character encodings may be specified indirectly by creating a file handle with the\ndesired encoding layer, which is then passed as an argument to new(). The specified encoding is\npropagated to files introduced by $INCLUDE directives.\n\nread\n$rr = $zonefile->read;\n@rr = $zonefile->read;\n\nWhen invoked in scalar context, read() returns a Net::DNS::RR object representing the next\nresource record encountered in the zone file, or undefined if end of data has been reached.\n\nWhen invoked in list context, read() returns the list of Net::DNS::RR objects in the order that\nthey appear in the zone file.\n\nComments and blank lines are silently disregarded.\n\n$INCLUDE, $ORIGIN, $TTL and $GENERATE directives are processed transparently.\n\nname\n$filename = $zonefile->name;\n\nReturns the name of the current zone file. Embedded $INCLUDE directives will cause this to\ndiffer from the filename argument supplied when the object was created.\n\nline\n$line = $zonefile->line;\n\nReturns the number of the last line read from the current zone file.\n\norigin\n$origin = $zonefile->origin;\n\nReturns the fully qualified name of the current origin within the zone file.\n\nttl\n$ttl = $zonefile->ttl;\n\nReturns the default TTL as specified by the $TTL directive.\n\nCOMPATIBILITY WITH Net::DNS::ZoneFile 1.04\nApplications which depended on the defunct Net::DNS::ZoneFile 1.04 CPAN distribution will\ncontinue to operate with minimal change using the compatibility interface described below. New\napplication code should use the object-oriented interface.\n\nuse Net::DNS::ZoneFile;\n\n$listref = Net::DNS::ZoneFile->read( $filename );\n$listref = Net::DNS::ZoneFile->read( $filename, $includedir );\n\n$listref = Net::DNS::ZoneFile->readfh( $filehandle );\n$listref = Net::DNS::ZoneFile->readfh( $filehandle, $includedir );\n\n$listref = Net::DNS::ZoneFile->parse(  $string );\n$listref = Net::DNS::ZoneFile->parse( \\$string );\n$listref = Net::DNS::ZoneFile->parse(  $string, $includedir );\n$listref = Net::DNS::ZoneFile->parse( \\$string, $includedir );\n\n$->print for @$listref;\n\nThe optional second argument specifies the default path for filenames. The current working\ndirectory is used by default.\n\nAlthough not available in the original implementation, the RR list can be obtained directly by\ncalling any of these methods in list context.\n\n@rr = Net::DNS::ZoneFile->read( $filename, $includedir );\n\nThe partial result is returned if an error is encountered by the parser.\n\nread\n$listref = Net::DNS::ZoneFile->read( $filename );\n$listref = Net::DNS::ZoneFile->read( $filename, $includedir );\n",
            "subsections": [
                {
                    "name": "read",
                    "content": "Net::DNS::RR objects. The return value is undefined if an error is encountered by the parser.\n\nreadfh\n$listref = Net::DNS::ZoneFile->readfh( $filehandle );\n$listref = Net::DNS::ZoneFile->readfh( $filehandle, $includedir );\n"
                },
                {
                    "name": "readfh",
                    "content": "Net::DNS::RR objects. The return value is undefined if an error is encountered by the parser.\n\nparse\n$listref = Net::DNS::ZoneFile->parse(  $string );\n$listref = Net::DNS::ZoneFile->parse( \\$string );\n$listref = Net::DNS::ZoneFile->parse(  $string, $includedir );\n$listref = Net::DNS::ZoneFile->parse( \\$string, $includedir );\n"
                },
                {
                    "name": "parse",
                    "content": "Net::DNS::RR objects. The return value is undefined if an error is encountered by the parser.\n"
                }
            ]
        },
        "ACKNOWLEDGEMENTS": {
            "content": "This package is designed as an improved and compatible replacement for Net::DNS::ZoneFile 1.04\nwhich was created by Luis Munoz in 2002 as a separate CPAN module.\n\nThe present implementation is the result of an agreement to merge our two different approaches\ninto one package integrated into Net::DNS. The contribution of Luis Munoz is gratefully\nacknowledged.\n\nThanks are also due to Willem Toorop for his constructive criticism of the initial version and\ninvaluable assistance during testing.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c)2011-2012 Dick Franks.\n\nAll rights reserved.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Permission to use, copy, modify, and distribute this software and its documentation for any\npurpose and without fee is hereby granted, provided that the original copyright notices appear\nin all copies and that both copyright notice and this permission notice appear in supporting\ndocumentation, and that the name of the author not be used in advertising or publicity\npertaining to distribution of the software without specific prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING\nBUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "perl, Net::DNS, Net::DNS::RR, RFC1035 Section 5.1, RFC2308\n\nBIND Administrator Reference Manual <http://bind.isc.org/>\n",
            "subsections": []
        }
    },
    "summary": "Net::DNS::ZoneFile - DNS zone file",
    "flags": [],
    "examples": [],
    "see_also": []
}