{
    "content": [
        {
            "type": "text",
            "text": "# Net::DNS::RR (perldoc)\n\n## NAME\n\nNet::DNS::RR - DNS resource record base class\n\n## SYNOPSIS\n\nuse Net::DNS;\n$rr = Net::DNS::RR->new('example.com IN AAAA 2001:DB8::1');\n$rr = Net::DNS::RR->new(\nowner   => 'example.com',\ntype    => 'AAAA',\naddress => '2001:DB8::1'\n);\n\n## DESCRIPTION\n\nNet::DNS::RR is the base class for DNS Resource Record (RR) objects. See also the manual pages\nfor each specific RR type.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **Sorting of RR arrays** (2 subsections)\n- **COPYRIGHT**\n- **LICENSE**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Net::DNS::RR",
        "section": "",
        "mode": "perldoc",
        "summary": "Net::DNS::RR - DNS resource record base class",
        "synopsis": "use Net::DNS;\n$rr = Net::DNS::RR->new('example.com IN AAAA 2001:DB8::1');\n$rr = Net::DNS::RR->new(\nowner   => 'example.com',\ntype    => 'AAAA',\naddress => '2001:DB8::1'\n);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 145,
                "subsections": []
            },
            {
                "name": "Sorting of RR arrays",
                "lines": 13,
                "subsections": [
                    {
                        "name": "set_rrsort_func",
                        "lines": 15
                    },
                    {
                        "name": "get_rrsort_func",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "COPYRIGHT",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Net::DNS::RR - DNS resource record base class\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Net::DNS;\n\n$rr = Net::DNS::RR->new('example.com IN AAAA 2001:DB8::1');\n\n$rr = Net::DNS::RR->new(\nowner   => 'example.com',\ntype    => 'AAAA',\naddress => '2001:DB8::1'\n);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Net::DNS::RR is the base class for DNS Resource Record (RR) objects. See also the manual pages\nfor each specific RR type.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "WARNING!!! Do not assume the RR objects you receive from a query are of a particular type. You\nmust always check the object type before calling any of its methods. If you call an unknown\nmethod, you will get an error message and execution will be terminated.\n\nnew (from string)\n$aaaa  = Net::DNS::RR->new('host.example.com. 86400 AAAA 2001:DB8::1');\n$mx    = Net::DNS::RR->new('example.com. 7200 MX 10 mailhost.example.com.');\n$cname = Net::DNS::RR->new('www.example.com 300 IN CNAME host.example.com');\n$txt   = Net::DNS::RR->new('txt.example.com 3600 HS TXT \"text data\"');\n\nReturns an object of the appropriate RR type, or a Net::DNS::RR object if the type is not\nimplemented. The attribute values are extracted from the string passed by the user. The syntax\nof the argument string follows the RFC1035 specification for zone files, and is compatible with\nthe result returned by the string method.\n\nThe owner and RR type are required; all other information is optional. Omitting the optional\nfields is useful for creating the empty RDATA sections required for certain dynamic update\noperations. See the Net::DNS::Update manual page for additional examples.\n\nAll names are interpreted as fully qualified domain names. The trailing dot (.) is optional.\n\nnew (from hash)\n$rr = Net::DNS::RR->new(%hash);\n\n$rr = Net::DNS::RR->new(\nowner   => 'host.example.com',\nttl     => 86400,\nclass   => 'IN',\ntype    => 'AAAA',\naddress => '2001:DB8::1'\n);\n\n$rr = Net::DNS::RR->new(\nowner   => 'txt.example.com',\ntype    => 'TXT',\ntxtdata => [ 'one', 'two' ]\n);\n\nReturns an object of the appropriate RR type, or a Net::DNS::RR object if the type is not\nimplemented. Consult the relevant manual pages for the usage of type specific attributes.\n\nThe owner and RR type are required; all other information is optional. Omitting optional\nattributes is useful for creating the empty RDATA sections required for certain dynamic update\noperations.\n\ndecode\n( $rr, $next ) = decode Net::DNS::RR( \\$data, $offset, @opaque );\n\nDecodes a DNS resource record at the specified location within a DNS packet.\n\nThe argument list consists of a reference to the buffer containing the packet data and offset\nindicating where resource record begins. Remaining arguments, if any, are passed as opaque data\nto subordinate decoders.\n\nReturns a \"Net::DNS::RR\" object and the offset of the next record in the packet.\n\nAn exception is raised if the data buffer contains insufficient or corrupt data.\n\nAny remaining arguments are passed as opaque data to subordinate decoders and do not form part\nof the published interface.\n\nencode\n$data = $rr->encode( $offset, @opaque );\n\nReturns the \"Net::DNS::RR\" in binary format suitable for inclusion in a DNS packet buffer.\n\nThe offset indicates the intended location within the packet data where the \"Net::DNS::RR\" is to\nbe stored.\n\nAny remaining arguments are opaque data which are passed intact to subordinate encoders.\n\ncanonical\n$data = $rr->canonical;\n\nReturns the \"Net::DNS::RR\" in canonical binary format suitable for DNSSEC signature validation.\n\nThe absence of the associative array argument signals to subordinate encoders that the canonical\nuncompressed lower case form of embedded domain names is to be used.\n\nprint\n$rr->print;\n\nPrints the resource record to the currently selected output filehandle. Calls the string method\nto get the formatted RR representation.\n\nstring\nprint $rr->string, \"\\n\";\n\nReturns a string representation of the RR using the master file format mandated by RFC1035. All\ndomain names are fully qualified with trailing dot. This differs from RR attribute methods,\nwhich omit the trailing dot.\n\nplain\n$plain = $rr->plain;\n\nReturns a simplified single-line representation of the RR. This facilitates interaction with\nprograms like nsupdate which have rudimentary parsers.\n\ntoken\n@token = $rr->token;\n\nReturns a token list representation of the RR zone file string.\n\ngeneric\n$generic = $rr->generic;\n\nReturns the generic RR representation defined in RFC3597. This facilitates creation of zone\nfiles containing RRs unrecognised by outdated nameservers and provisioning software.\n\nowner name\n$name = $rr->owner;\n\nReturns the owner name of the record.\n\ntype\n$type = $rr->type;\n\nReturns the record type.\n\nclass\n$class = $rr->class;\n\nResource record class.\n\nttl\n$ttl = $rr->ttl;\n$ttl = $rr->ttl(3600);\n\nResource record time to live in seconds.\n\nrdata\n$rr = Net::DNS::RR->new( type => NULL, rdata => 'arbitrary' );\n\nResource record data section when viewed as opaque octets.\n\nrdstring\n$rdstring = $rr->rdstring;\n\nReturns a string representation of the RR-specific data.\n\nrdlength\n$rdlength = $rr->rdlength;\n\nReturns the uncompressed length of the encoded RR-specific data.\n",
                "subsections": []
            },
            "Sorting of RR arrays": {
                "content": "Sorting of RR arrays is done by Net::DNS::rrsort(), see documentation for Net::DNS. This package\nprovides class methods to set the comparator function used for a particular RR based on its\nattributes.\n\nsetrrsortfunc\nmy $function = sub {                ## numerically ascending order\n$Net::DNS::a->{'preference'} <=> $Net::DNS::b->{'preference'};\n};\n\nNet::DNS::RR::MX->setrrsortfunc( 'preference', $function );\n\nNet::DNS::RR::MX->setrrsortfunc( 'defaultsort', $function );\n",
                "subsections": [
                    {
                        "name": "set_rrsort_func",
                        "content": "which the sorting is to take place. If you specify \"defaultsort\" then that is the sort\nalgorithm that will be used when getrrsortfunc() is called without an RR attribute as\nargument.\n\nThe second argument is a reference to a comparator function that uses the global variables $a\nand $b in the Net::DNS package. During sorting, the variables $a and $b will contain references\nto objects of the class whose setrrsortfunc() was called. The above sorting function will only\nbe applied to Net::DNS::RR::MX objects.\n\nThe above example is the sorting function implemented in MX.\n\ngetrrsortfunc\n$function = Net::DNS::RR::MX->getrrsortfunc('preference');\n$function = Net::DNS::RR::MX->getrrsortfunc();\n"
                    },
                    {
                        "name": "get_rrsort_func",
                        "content": ""
                    }
                ]
            },
            "COPYRIGHT": {
                "content": "Copyright (c)1997-2001 Michael Fuhr.\n\nPortions Copyright (c)2002,2003 Chris Reinhardt.\n\nPortions Copyright (c)2005-2007 Olaf Kolkman.\n\nPortions Copyright (c)2007,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::Question, Net::DNS::Packet, Net::DNS::Update, RFC1035 Section 4.1.3,\nRFC1123, RFC3597\n",
                "subsections": []
            }
        }
    }
}