{
    "mode": "perldoc",
    "parameter": "HTML::HeadParser",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/HTML%3A%3AHeadParser/json",
    "generated": "2026-06-12T06:20:04Z",
    "synopsis": "require HTML::HeadParser;\n$p = HTML::HeadParser->new;\n$p->parse($text) and  print \"not finished\";\n$p->header('Title')          # to access <title>....</title>\n$p->header('Content-Base')   # to access <base href=\"http://...\">\n$p->header('Foo')            # to access <meta http-equiv=\"Foo\" content=\"...\">\n$p->header('X-Meta-Author')  # to access <meta name=\"author\" content=\"...\">\n$p->header('X-Meta-Charset') # to access <meta charset=\"...\">",
    "sections": {
        "NAME": {
            "content": "HTML::HeadParser - Parse <HEAD> section of a HTML document\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "require HTML::HeadParser;\n$p = HTML::HeadParser->new;\n$p->parse($text) and  print \"not finished\";\n\n$p->header('Title')          # to access <title>....</title>\n$p->header('Content-Base')   # to access <base href=\"http://...\">\n$p->header('Foo')            # to access <meta http-equiv=\"Foo\" content=\"...\">\n$p->header('X-Meta-Author')  # to access <meta name=\"author\" content=\"...\">\n$p->header('X-Meta-Charset') # to access <meta charset=\"...\">\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"HTML::HeadParser\" is a specialized (and lightweight) \"HTML::Parser\" that will only parse\nthe <HEAD>...</HEAD> section of an HTML document. The parse() method will return a FALSE value\nas soon as some <BODY> element or body text are found, and should not be called again after\nthis.\n\nNote that the \"HTML::HeadParser\" might get confused if raw undecoded UTF-8 is passed to the",
            "subsections": [
                {
                    "name": "parse",
                    "content": "The \"HTML::HeadParser\" keeps a reference to a header object, and the parser will update this\nheader object as the various elements of the <HEAD> section of the HTML document are recognized.\nThe following header fields are affected:\n\nContent-Base:\nThe *Content-Base* header is initialized from the <base href=\"...\"> element.\n\nTitle:\nThe *Title* header is initialized from the <title>...</title> element.\n\nIsindex:\nThe *Isindex* header will be added if there is a <isindex> element in the <head>. The header\nvalue is initialized from the *prompt* attribute if it is present. If no *prompt* attribute\nis given it will have '?' as the value.\n\nX-Meta-Foo:\nAll <meta> elements containing a \"name\" attribute will result in headers using the prefix\n\"X-Meta-\" appended with the value of the \"name\" attribute as the name of the header, and the\nvalue of the \"content\" attribute as the pushed header value.\n\n<meta> elements containing a \"http-equiv\" attribute will result in headers as in above, but\nwithout the \"X-Meta-\" prefix in the header name.\n\n<meta> elements containing a \"charset\" attribute will result in an \"X-Meta-Charset\" header,\nusing the value of the \"charset\" attribute as the pushed header value.\n\nThe ':' character can't be represented in header field names, so if the meta element\ncontains this char it's substituted with '-' before forming the field name.\n"
                }
            ]
        },
        "METHODS": {
            "content": "The following methods (in addition to those provided by the superclass) are available:\n\n$hp = HTML::HeadParser->new\n$hp = HTML::HeadParser->new( $header )\nThe object constructor. The optional $header argument should be a reference to an object\nthat implement the header() and pushheader() methods as defined by the \"HTTP::Headers\"\nclass. Normally it will be of some class that is a or delegates to the \"HTTP::Headers\"\nclass.\n\nIf no $header is given \"HTML::HeadParser\" will create an \"HTTP::Headers\" object by itself\n(initially empty).\n\n$hp->header;\nReturns a reference to the header object.\n\n$hp->header( $key )\nReturns a header value. It is just a shorter way to write \"$hp->header->header($key)\".\n",
            "subsections": []
        },
        "EXAMPLE": {
            "content": "$h = HTTP::Headers->new;\n$p = HTML::HeadParser->new($h);\n$p->parse(<<EOT);\n<title>Stupid example</title>\n<base href=\"http://www.linpro.no/lwp/\">\nNormal text starts here.\nEOT\nundef $p;\nprint $h->title;   # should print \"Stupid example\"\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "HTML::Parser, HTTP::Headers\n\nThe \"HTTP::Headers\" class is distributed as part of the *libwww-perl* package. If you don't have\nthat distribution installed you need to provide the $header argument to the \"HTML::HeadParser\"\nconstructor with your own object that implements the documented protocol.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 1996-2001 Gisle Aas. All rights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "HTML::HeadParser - Parse <HEAD> section of a HTML document",
    "flags": [],
    "examples": [
        "$h = HTTP::Headers->new;",
        "$p = HTML::HeadParser->new($h);",
        "$p->parse(<<EOT);",
        "<title>Stupid example</title>",
        "<base href=\"http://www.linpro.no/lwp/\">",
        "Normal text starts here.",
        "EOT",
        "undef $p;",
        "print $h->title;   # should print \"Stupid example\""
    ],
    "see_also": []
}