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

📄 perlport.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 5 页
字号:
.\" 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 "PERLPORT 1".TH PERLPORT 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"perlport \- Writing portable Perl.SH "DESCRIPTION".IX Header "DESCRIPTION"Perl runs on numerous operating systems.  While most of them sharemuch in common, they also have their own unique features..PPThis document is meant to help you to find out what constitutes portablePerl code.  That way once you make a decision to write portably,you know where the lines are drawn, and you can stay within them..PPThere is a tradeoff between taking full advantage of one particulartype of computer and taking advantage of a full range of them.Naturally, as you broaden your range and become more diverse, thecommon factors drop, and you are left with an increasingly smallerarea of common ground in which you can operate to accomplish aparticular task.  Thus, when you begin attacking a problem, it isimportant to consider under which part of the tradeoff curve youwant to operate.  Specifically, you must decide whether it isimportant that the task that you are coding have the full generalityof being portable, or whether to just get the job done right now.This is the hardest choice to be made.  The rest is easy, becausePerl provides many choices, whichever way you want to approach yourproblem..PPLooking at it another way, writing portable code is usually aboutwillfully limiting your available choices.  Naturally, it takesdiscipline and sacrifice to do that.  The product of portabilityand convenience may be a constant.  You have been warned..PPBe aware of two important points:.IP "Not all Perl programs have to be portable" 4.IX Item "Not all Perl programs have to be portable"There is no reason you should not use Perl as a language to glue Unixtools together, or to prototype a Macintosh application, or to manage theWindows registry.  If it makes no sense to aim for portability for onereason or another in a given program, then don't bother..IP "Nearly all of Perl already \fIis\fR portable" 4.IX Item "Nearly all of Perl already is portable"Don't be fooled into thinking that it is hard to create portable Perlcode.  It isn't.  Perl tries its level-best to bridge the gaps betweenwhat's available on different platforms, and all the means available touse those features.  Thus almost all Perl code runs on any machinewithout modification.  But there are some significant issues inwriting portable code, and this document is entirely about those issues..PPHere's the general rule: When you approach a task commonly doneusing a whole range of platforms, think about writing portablecode.  That way, you don't sacrifice much by way of the implementationchoices you can avail yourself of, and at the same time you can giveyour users lots of platform choices.  On the other hand, when you have totake advantage of some unique feature of a particular platform, as isoften the case with systems programming (whether for Unix, Windows,Mac\ \s-1OS\s0, \s-1VMS\s0, etc.), consider writing platform-specific code..PPWhen the code will run on only two or three operating systems, youmay need to consider only the differences of those particular systems.The important thing is to decide where the code will run and to bedeliberate in your decision..PPThe material below is separated into three main sections: main issues ofportability (\*(L"\s-1ISSUES\s0\*(R"), platform-specific issues (\*(L"\s-1PLATFORMS\s0\*(R"), andbuilt-in perl functions that behave differently on various ports(\*(L"\s-1FUNCTION\s0 \s-1IMPLEMENTATIONS\s0\*(R")..PPThis information should not be considered complete; it includes possiblytransient information about idiosyncrasies of some of the ports, almostall of which are in a state of constant evolution.  Thus, this materialshould be considered a perpetual work in progress(\f(CW\*(C`<IMG SRC="yellow_sign.gif" ALT="Under Construction">\*(C'\fR)..SH "ISSUES".IX Header "ISSUES".Sh "Newlines".IX Subsection "Newlines"In most operating systems, lines in files are terminated by newlines.Just what is used as a newline may vary from \s-1OS\s0 to \s-1OS\s0.  Unixtraditionally uses \f(CW\*(C`\e012\*(C'\fR, one type of DOSish I/O uses \f(CW\*(C`\e015\e012\*(C'\fR,and Mac\ \s-1OS\s0 uses \f(CW\*(C`\e015\*(C'\fR..PPPerl uses \f(CW\*(C`\en\*(C'\fR to represent the \*(L"logical\*(R" newline, where what islogical may depend on the platform in use.  In MacPerl, \f(CW\*(C`\en\*(C'\fR alwaysmeans \f(CW\*(C`\e015\*(C'\fR.  In DOSish perls, \f(CW\*(C`\en\*(C'\fR usually means \f(CW\*(C`\e012\*(C'\fR, butwhen accessing a file in \*(L"text\*(R" mode, \s-1STDIO\s0 translates it to (orfrom) \f(CW\*(C`\e015\e012\*(C'\fR, depending on whether you're reading or writing.Unix does the same thing on ttys in canonical mode.  \f(CW\*(C`\e015\e012\*(C'\fRis commonly referred to as \s-1CRLF\s0..PPTo trim trailing newlines from text lines use \fIchomp()\fR.  With default settings that function looks for a trailing \f(CW\*(C`\en\*(C'\fR character and thus trims in a portable way..PPWhen dealing with binary files (or text files in binary mode) be sureto explicitly set $/ to the appropriate value for your file formatbefore using \fIchomp()\fR..PPBecause of the \*(L"text\*(R" mode translation, DOSish perls have limitationsin using \f(CW\*(C`seek\*(C'\fR and \f(CW\*(C`tell\*(C'\fR on a file accessed in \*(L"text\*(R" mode.Stick to \f(CW\*(C`seek\*(C'\fR\-ing to locations you got from \f(CW\*(C`tell\*(C'\fR (and noothers), and you are usually free to use \f(CW\*(C`seek\*(C'\fR and \f(CW\*(C`tell\*(C'\fR evenin \*(L"text\*(R" mode.  Using \f(CW\*(C`seek\*(C'\fR or \f(CW\*(C`tell\*(C'\fR or other file operationsmay be non-portable.  If you use \f(CW\*(C`binmode\*(C'\fR on a file, however, youcan usually \f(CW\*(C`seek\*(C'\fR and \f(CW\*(C`tell\*(C'\fR with arbitrary values in safety..PPA common misconception in socket programming is that \f(CW\*(C`\en\*(C'\fR eq \f(CW\*(C`\e012\*(C'\fReverywhere.  When using protocols such as common Internet protocols,\&\f(CW\*(C`\e012\*(C'\fR and \f(CW\*(C`\e015\*(C'\fR are called for specifically, and the values ofthe logical \f(CW\*(C`\en\*(C'\fR and \f(CW\*(C`\er\*(C'\fR (carriage return) are not reliable..PP.Vb 2\&    print SOCKET "Hi there, client!\er\en";      # WRONG\&    print SOCKET "Hi there, client!\e015\e012";  # RIGHT.Ve.PPHowever, using \f(CW\*(C`\e015\e012\*(C'\fR (or \f(CW\*(C`\ecM\ecJ\*(C'\fR, or \f(CW\*(C`\ex0D\ex0A\*(C'\fR) can be tediousand unsightly, as well as confusing to those maintaining the code.  Assuch, the Socket module supplies the Right Thing for those who want it..PP.Vb 2\&    use Socket qw(:DEFAULT :crlf);\&    print SOCKET "Hi there, client!$CRLF"      # RIGHT.Ve.PPWhen reading from a socket, remember that the default input recordseparator \f(CW$/\fR is \f(CW\*(C`\en\*(C'\fR, but robust socket code will recognize aseither \f(CW\*(C`\e012\*(C'\fR or \f(CW\*(C`\e015\e012\*(C'\fR as end of line:.PP.Vb 3\&    while (<SOCKET>) {\&        # ...\&    }.Ve.PPBecause both \s-1CRLF\s0 and \s-1LF\s0 end in \s-1LF\s0, the input record separator canbe set to \s-1LF\s0 and any \s-1CR\s0 stripped later.  Better to write:.PP.Vb 2\&    use Socket qw(:DEFAULT :crlf);\&    local($/) = LF;      # not needed if $/ is already \e012\&\&    while (<SOCKET>) {\&        s/$CR?$LF/\en/;   # not sure if socket uses LF or CRLF, OK\&    #   s/\e015?\e012/\en/; # same thing\&    }.Ve

⌨️ 快捷键说明

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