⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perlfaq9.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 3 页
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings.  \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote.  \*(C+ will.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\.    ds -- \(*W-.    ds PI pi.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch.    ds L" "".    ds R" "".    ds C` "".    ds C' ""'br\}.el\{\.    ds -- \|\(em\|.    ds PI \(*p.    ds L" ``.    ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el       .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD.  Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\.    de IX.    tm Index:\\$1\t\\n%\t"\\$2"...    nr % 0.    rr F.\}.el \{\.    de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear.  Run.  Save yourself.  No user-serviceable parts..    \" fudge factors for nroff and troff.if n \{\.    ds #H 0.    ds #V .8m.    ds #F .3m.    ds #[ \f1.    ds #] \fP.\}.if t \{\.    ds #H ((1u-(\\\\n(.fu%2u))*.13m).    ds #V .6m.    ds #F 0.    ds #[ \&.    ds #] \&.\}.    \" simple accents for nroff and troff.if n \{\.    ds ' \&.    ds ` \&.    ds ^ \&.    ds , \&.    ds ~ ~.    ds /.\}.if t \{\.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u".    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}.    \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E.    \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'.    \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\.    ds : e.    ds 8 ss.    ds o a.    ds d- d\h'-1'\(ga.    ds D- D\h'-1'\(hy.    ds th \o'bp'.    ds Th \o'LP'.    ds ae ae.    ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLFAQ9 1".TH PERLFAQ9 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification.  Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perlfaq9 \- Networking ($Revision: 8539 $).SH "DESCRIPTION".IX Header "DESCRIPTION"This section deals with questions related to networking, the internet,and a few on the web..Sh "What is the correct form of response from a \s-1CGI\s0 script?".IX Subsection "What is the correct form of response from a CGI script?"(Alan Flavell <flavell+www@a5.ph.gla.ac.uk> answers...).PPThe Common Gateway Interface (\s-1CGI\s0) specifies a software interface betweena program (\*(L"\s-1CGI\s0 script\*(R") and a web server (\s-1HTTPD\s0). It is not specificto Perl, and has its own FAQs and tutorials, and usenet group,comp.infosystems.www.authoring.cgi.PPThe \s-1CGI\s0 specification is outlined in an informational \s-1RFC:\s0http://www.ietf.org/rfc/rfc3875.PPOther relevant documentation listed in: http://www.perl.org/CGI_MetaFAQ.html.PPThese Perl FAQs very selectively cover some \s-1CGI\s0 issues. However, Perlprogrammers are strongly advised to use the \s-1CGI\s0.pm module, to take careof the details for them..PPThe similarity between \s-1CGI\s0 response headers (defined in the \s-1CGI\s0specification) and \s-1HTTP\s0 response headers (defined in the \s-1HTTP\s0specification, \s-1RFC2616\s0) is intentional, but can sometimes be confusing..PPThe \s-1CGI\s0 specification defines two kinds of script: the \*(L"Parsed Header\*(R"script, and the \*(L"Non Parsed Header\*(R" (\s-1NPH\s0) script. Check your serverdocumentation to see what it supports. \*(L"Parsed Header\*(R" scripts aresimpler in various respects. The \s-1CGI\s0 specification allows any of theusual newline representations in the \s-1CGI\s0 response (it's the server'sjob to create an accurate \s-1HTTP\s0 response based on it). So \*(L"\en\*(R" written intext mode is technically correct, and recommended. \s-1NPH\s0 scripts are moretricky: they must put out a complete and accurate set of \s-1HTTP\s0transaction response headers; the \s-1HTTP\s0 specification calls for recordsto be terminated with carriage-return and line-feed, i.e \s-1ASCII\s0 \e015\e012written in binary mode..PPUsing \s-1CGI\s0.pm gives excellent platform independence, including \s-1EBCDIC\s0systems. \s-1CGI\s0.pm selects an appropriate newline representation($CGI::CRLF) and sets binmode as appropriate..Sh "My \s-1CGI\s0 script runs from the command line but not the browser.  (500 Server Error)".IX Subsection "My CGI script runs from the command line but not the browser.  (500 Server Error)"Several things could be wrong.  You can go through the \*(L"TroubleshootingPerl \s-1CGI\s0 scripts\*(R" guide at.PP.Vb 1\&        http://www.perl.org/troubleshooting_CGI.html.Ve.PPIf, after that, you can demonstrate that you've read the FAQs and thatyour problem isn't something simple that can be easily answered, you'llprobably receive a courteous and useful reply to your question if youpost it on comp.infosystems.www.authoring.cgi (if it's something to dowith \s-1HTTP\s0 or the \s-1CGI\s0 protocols).  Questions that appear to be Perlquestions but are really \s-1CGI\s0 ones that are posted to comp.lang.perl.miscare not so well received..PPThe useful FAQs, related documents, and troubleshooting guides arelisted in the \s-1CGI\s0 Meta \s-1FAQ:\s0.PP.Vb 1\&        http://www.perl.org/CGI_MetaFAQ.html.Ve.Sh "How can I get better error messages from a \s-1CGI\s0 program?".IX Subsection "How can I get better error messages from a CGI program?"Use the CGI::Carp module.  It replaces \f(CW\*(C`warn\*(C'\fR and \f(CW\*(C`die\*(C'\fR, plus thenormal Carp modules \f(CW\*(C`carp\*(C'\fR, \f(CW\*(C`croak\*(C'\fR, and \f(CW\*(C`confess\*(C'\fR functions withmore verbose and safer versions.  It still sends them to the normalserver error log..PP.Vb 3\&    use CGI::Carp;\&    warn "This is a complaint";\&    die "But this one is serious";.Ve.PPThe following use of CGI::Carp also redirects errors to a file of your choice,placed in a \s-1BEGIN\s0 block to catch compile-time warnings as well:.PP.Vb 6\&    BEGIN {\&        use CGI::Carp qw(carpout);\&        open(LOG, ">>/var/local/cgi\-logs/mycgi\-log")\&            or die "Unable to append to mycgi\-log: $!\en";\&        carpout(*LOG);\&    }.Ve.PPYou can even arrange for fatal errors to go back to the client browser,which is nice for your own debugging, but might confuse the end user..PP.Vb 2\&    use CGI::Carp qw(fatalsToBrowser);\&    die "Bad error here";.Ve.PPEven if the error happens before you get the \s-1HTTP\s0 header out, the modulewill try to take care of this to avoid the dreaded server 500 errors.Normal warnings still go out to the server error log (or whereveryou've sent them with \f(CW\*(C`carpout\*(C'\fR) with the application name and datestamp prepended..Sh "How do I remove \s-1HTML\s0 from a string?".IX Subsection "How do I remove HTML from a string?"The most correct way (albeit not the fastest) is to use HTML::Parserfrom \s-1CPAN\s0.  Another mostly correctway is to use HTML::FormatText which not only removes \s-1HTML\s0 but alsoattempts to do a little simple formatting of the resulting plain text..PPMany folks attempt a simple-minded regular expression approach, like\&\f(CW\*(C`s/<.*?>//g\*(C'\fR, but that fails in many cases because the tagsmay continue over line breaks, they may contain quoted angle-brackets,or \s-1HTML\s0 comment may be present.  Plus, folks forget to convertentities\*(--like \f(CW\*(C`&lt;\*(C'\fR for example..PPHere's one \*(L"simple-minded\*(R" approach, that works for most files:.PP.Vb 2\&    #!/usr/bin/perl \-p0777\&    s/<(?:[^>\*(Aq"]*|([\*(Aq"]).*?\e1)*>//gs.Ve.PPIf you want a more complete solution, see the 3\-stage striphtmlprogram inhttp://www.cpan.org/authors/Tom_Christiansen/scripts/striphtml.gz\&..PPHere are some tricky cases that you should think about when pickinga solution:.PP.Vb 1\&    <IMG SRC = "foo.gif" ALT = "A > B">\&\&    <IMG SRC = "foo.gif"\&         ALT = "A > B">\&\&    <!\-\- <A comment> \-\->\&\&    <script>if (a<b && a>c)</script>\&\&    <# Just data #>\&\&    <![INCLUDE CDATA [ >>>>>>>>>>>> ]]>.Ve.PPIf \s-1HTML\s0 comments include other tags, those solutions would also breakon text like this:

⌨️ 快捷键说明

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