ch08_39.htm

来自「by Randal L. Schwartz and Tom Phoenix I」· HTM 代码 · 共 100 行

HTM
100
字号
<html><head><title>CGI::Push (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_38.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch08_40.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">8.39. CGI::Push</h2><p><a name="INDEX-1318" />Provides an interface to do server pushoperations, letting you rewrite pages with content that changesregularly. A server push operation automatically sends updates to apage on a push-capable browser. CGI::Push exports the function<tt class="literal">do_push</tt> to implement page redraws. This method canbe used on a CGI::Push object or on its own:</p><blockquote><pre class="code">$q = new CGI::Push;$q-&gt;do_push(-next_page =&gt; \&amp;sub);</pre></blockquote><p>or:</p><blockquote><pre class="code">do_push (-next_page =&gt; \&amp;sub);</pre></blockquote><p><tt class="literal">do_push</tt> requires one argument: a reference to asubroutine that will draw the next page. You may optionally specify asubroutine that draws the last page and the interval between pageupdates. Additional parameters to <tt class="literal">do_push</tt> arethose that can be used with a CGI::headers object.</p><a name="INDEX-1319" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>do_push</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre><a name="INDEX-1319" />do_push (<em class="replaceable">params</em>)</pre><p>Implements a server push operation, which updates a page at specificintervals. Parameters are:</p><dl><dt><b><tt class="literal">-delay =&gt;</tt> <em class="replaceable">n</em></b></dt><dd>Specifies the number of seconds, <em class="replaceable"><tt>n</tt></em>, towait before the next call to the page-drawing subroutine.</p></dd><dt><b><tt class="literal">-last_page =&gt;</tt> <tt class="literal">\&amp;</tt><em class="replaceable">sublast</em></b></dt><dd>Runs the subroutine <em class="replaceable"><tt>sublast</tt></em> to draw thelast page update of a server push operation. The<tt class="literal">-last_page</tt> routine is invoked when the<tt class="literal">-next_page</tt> routine returns false. A reference to asubroutine glob should be provided for this parameter, but the nameof the subroutine is also acceptable.</p></dd><dt><b><tt class="literal">-next_page =&gt;</tt> <tt class="literal">\&amp;</tt><em class="replaceable">sub</em></b></dt><dd><em class="replaceable"><tt>sub</tt></em> is the name of the subroutineresponsible for redrawing the page and counting the number ofiterations (if you want repeated updating). The<tt class="literal">do_push</tt> routine ends when<em class="replaceable"><tt>sub</tt></em> returns false (or when the<tt class="literal">-last_page</tt> subroutine is invoked). A reference toa subroutine glob should be provided for this parameter, but the nameof the subroutine is also acceptable.</p></dd><dt><b><tt class="literal">-type =</tt> <em class="replaceable">string</em></b></dt><dd>Specifies the content type of the pushed data. The default value is<tt class="literal">text/html</tt>.</p></dd></dl></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_38.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch08_40.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">8.38. CGI::Pretty</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">8.40. CGI::Switch</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?