{
    "mode": "perldoc",
    "parameter": "CGI::Push",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3APush/json",
    "generated": "2026-06-13T21:28:05Z",
    "synopsis": "use strict;\nuse warnings;\nuse CGI::Push qw(:standard);\ndopush(\n-nextpage => \\&nextpage,\n-lastpage => \\&lastpage,\n-delay     => 0.5\n);\nsub nextpage {\nmy($q,$counter) = @;\nreturn undef if $counter >= 10;\n....\n}\nsub lastpage {\nmy($q,$counter) = @;\nreturn ...\n}",
    "sections": {
        "NAME": {
            "content": "CGI::Push - Simple Interface to Server Push\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use strict;\nuse warnings;\n\nuse CGI::Push qw(:standard);\n\ndopush(\n-nextpage => \\&nextpage,\n-lastpage => \\&lastpage,\n-delay     => 0.5\n);\n\nsub nextpage {\nmy($q,$counter) = @;\nreturn undef if $counter >= 10;\n....\n}\n\nsub lastpage {\nmy($q,$counter) = @;\nreturn ...\n}\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "CGI::Push is a subclass of the CGI object created by CGI.pm. It is specialized for server push\noperations, which allow you to create animated pages whose content changes at regular intervals.\n\nYou provide CGI::Push with a pointer to a subroutine that will draw one page. Every time your\nsubroutine is called, it generates a new page. The contents of the page will be transmitted to\nthe browser in such a way that it will replace what was there beforehand. The technique will\nwork with HTML pages as well as with graphics files, allowing you to create animated GIFs.\n\nOnly Netscape Navigator supports server push. Internet Explorer browsers do not.\n\nUSING CGI::Push\nCGI::Push adds one new method to the standard CGI suite, dopush(). When you call this method,\nyou pass it a reference to a subroutine that is responsible for drawing each new page, an\ninterval delay, and an optional subroutine for drawing the last page. Other optional parameters\ninclude most of those recognized by the CGI header() method.\n\nYou may call dopush() in the object oriented manner or not, as you prefer:\n\nuse CGI::Push;\n$q = CGI::Push->new;\n$q->dopush(-nextpage=>\\&drawapage);\n\n-or-\n\nuse CGI::Push qw(:standard);\ndopush(-nextpage=>\\&drawapage);\n\nParameters are as follows:\n",
            "subsections": [
                {
                    "name": "-next_page",
                    "content": "dopush(-nextpage=>\\&mydrawroutine);\n\nThis required parameter points to a reference to a subroutine responsible for drawing each\nnew page. The subroutine should expect two parameters consisting of the CGI object and a\ncounter indicating the number of times the subroutine has been called. It should return the\ncontents of the page as an array of one or more items to print. It can return a false value\n(or an empty array) in order to abort the redrawing loop and print out the final page (if\nany)\n\nsub mydrawroutine {\nmy($q,$counter) = @;\nreturn undef if $counter > 100;\n...\n}\n\nYou are of course free to refer to create and use global variables within your draw routine\nin order to achieve special effects.\n"
                },
                {
                    "name": "-last_page",
                    "content": "This optional parameter points to a reference to the subroutine responsible for drawing the\nlast page of the series. It is called after the -nextpage routine returns a false value.\nThe subroutine itself should have exactly the same calling conventions as the -nextpage\nroutine.\n"
                },
                {
                    "name": "-type",
                    "content": "This optional parameter indicates the content type of each page. It defaults to \"text/html\".\nNormally the module assumes that each page is of a homogeneous MIME type. However if you\nprovide either of the magic values \"heterogeneous\" or \"dynamic\" (the latter provided for the\nconvenience of those who hate long parameter names), you can specify the MIME type -- and\nother header fields -- on a per-page basis. See \"heterogeneous pages\" for more details.\n"
                },
                {
                    "name": "-delay",
                    "content": "This indicates the delay, in seconds, between frames. Smaller delays refresh the page\nfaster. Fractional values are allowed.\n\nIf not specified, -delay will default to 1 second\n"
                },
                {
                    "name": "-cookie, -target, -expires, -nph",
                    "content": "These have the same meaning as the like-named parameters in CGI::header().\n\nIf not specified, -nph will default to 1 (as needed for many servers, see below).\n"
                },
                {
                    "name": "Heterogeneous Pages",
                    "content": "Ordinarily all pages displayed by CGI::Push share a common MIME type. However by providing a\nvalue of \"heterogeneous\" or \"dynamic\" in the dopush() -type parameter, you can specify the MIME\ntype of each page on a case-by-case basis.\n\nIf you use this option, you will be responsible for producing the HTTP header for each page.\nSimply modify your draw routine to look like this:\n\nsub mydrawroutine {\nmy($q,$counter) = @;\nreturn header('text/html'),   # note we're producing the header here\n....\n}\n\nYou can add any header fields that you like, but some (cookies and status fields included) may\nnot be interpreted by the browser. One interesting effect is to display a series of pages, then,\nafter the last page, to redirect the browser to a new URL. Because redirect() does b<not> work,\nthe easiest way is with a -refresh header field, as shown below:\n\nsub mydrawroutine {\nmy($q,$counter) = @;\nreturn undef if $counter > 10;\nreturn header('text/html'),   # note we're producing the header here\n...\n}\n\nsub mylastpage {\nreturn header(-refresh=>'5; URL=http://somewhere.else/finished.html',\n-type=>'text/html'),\n...\n}\n"
                },
                {
                    "name": "Changing the Page Delay on the Fly",
                    "content": "If you would like to control the delay between pages on a page-by-page basis, call pushdelay()\nfrom within your draw routine. pushdelay() takes a single numeric argument representing the\nnumber of seconds you wish to delay after the current page is displayed and before displaying\nthe next one. The delay may be fractional. Without parameters, pushdelay() just returns the\ncurrent delay.\n\nINSTALLING CGI::Push SCRIPTS\nServer push scripts must be installed as no-parsed-header (NPH) scripts in order to work\ncorrectly on many servers. On Unix systems, this is most often accomplished by prefixing the\nscript's name with \"nph-\". Recognition of NPH scripts happens automatically with WebSTAR and\nMicrosoft IIS. Users of other servers should see their documentation for help.\n\nApache web server from version 1.3b2 on does not need server push scripts installed as NPH\nscripts: the -nph parameter to dopush() may be set to a false value to disable the extra\nheaders needed by an NPH script.\n"
                }
            ]
        },
        "AUTHOR INFORMATION": {
            "content": "The CGI.pm distribution is copyright 1995-2007, Lincoln D. Stein. It is distributed under the\nArtistic License 2.0. It is currently maintained by Lee Johnson with help from many\ncontributors.\n\nAddress bug reports and comments to: https://github.com/leejo/CGI.pm/issues\n\nThe original bug tracker can be found at:\nhttps://rt.cpan.org/Public/Dist/Display.html?Queue=CGI.pm\n\nWhen sending bug reports, please provide the version of CGI.pm, the version of Perl, the name\nand version of your Web server, and the name and version of the operating system you are using.\nIf the problem is even remotely browser dependent, please provide information about the affected\nbrowsers as well. Copyright 1995-1998, Lincoln D. Stein. All rights reserved.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "This section intentionally left blank.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CGI::Carp, CGI\n",
            "subsections": []
        }
    },
    "summary": "CGI::Push - Simple Interface to Server Push",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "dopush(-nextpage=>\\&mydrawroutine); This required parameter points to a reference to a subroutine responsible for drawing each new page. The subroutine should expect two parameters consisting of the CGI object and a counter indicating the number of times the subroutine has been called. It should return the contents of the page as an array of one or more items to print. It can return a false value (or an empty array) in order to abort the redrawing loop and print out the final page (if any) sub mydrawroutine { my($q,$counter) = @; return undef if $counter > 100; ... } You are of course free to refer to create and use global variables within your draw routine in order to achieve special effects."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This optional parameter points to a reference to the subroutine responsible for drawing the last page of the series. It is called after the -nextpage routine returns a false value. The subroutine itself should have exactly the same calling conventions as the -nextpage routine."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This optional parameter indicates the content type of each page. It defaults to \"text/html\". Normally the module assumes that each page is of a homogeneous MIME type. However if you provide either of the magic values \"heterogeneous\" or \"dynamic\" (the latter provided for the convenience of those who hate long parameter names), you can specify the MIME type -- and other header fields -- on a per-page basis. See \"heterogeneous pages\" for more details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This indicates the delay, in seconds, between frames. Smaller delays refresh the page faster. Fractional values are allowed. If not specified, -delay will default to 1 second"
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "These have the same meaning as the like-named parameters in CGI::header(). If not specified, -nph will default to 1 (as needed for many servers, see below)."
        }
    ],
    "examples": [],
    "see_also": []
}