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

📄 perlintro.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 2 页
字号:
.\" 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 "PERLINTRO 1".TH PERLINTRO 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"perlintro \-\- a brief introduction and overview of Perl.SH "DESCRIPTION".IX Header "DESCRIPTION"This document is intended to give you a quick overview of the Perlprogramming language, along with pointers to further documentation.  Itis intended as a \*(L"bootstrap\*(R" guide for those who are new to thelanguage, and provides just enough information for you to be able toread other peoples' Perl and understand roughly what it's doing, orwrite your own simple scripts..PPThis introductory document does not aim to be complete.  It does noteven aim to be entirely accurate.  In some cases perfection has beensacrificed in the goal of getting the general idea across.  You are\&\fIstrongly\fR advised to follow this introduction with more informationfrom the full Perl manual, the table of contents to which can be foundin perltoc..PPThroughout this document you'll see references to other parts of thePerl documentation.  You can read that documentation using the \f(CW\*(C`perldoc\*(C'\fRcommand or whatever method you're using to read this document..Sh "What is Perl?".IX Subsection "What is Perl?"Perl is a general-purpose programming language originally developed fortext manipulation and now used for a wide range of tasks includingsystem administration, web development, network programming, \s-1GUI\s0development, and more..PPThe language is intended to be practical (easy to use, efficient,complete) rather than beautiful (tiny, elegant, minimal).  Its majorfeatures are that it's easy to use, supports both procedural andobject-oriented (\s-1OO\s0) programming, has powerful built-in support for textprocessing, and has one of the world's most impressive collections ofthird-party modules..PPDifferent definitions of Perl are given in perl, perlfaq1 andno doubt other places.  From this we can determine that Perl is differentthings to different people, but that lots of people think it's at leastworth writing about..Sh "Running Perl programs".IX Subsection "Running Perl programs"To run a Perl program from the Unix command line:.PP.Vb 1\&    perl progname.pl.Ve.PPAlternatively, put this as the first line of your script:.PP.Vb 1\&    #!/usr/bin/env perl.Ve.PP\&... and run the script as \f(CW\*(C`/path/to/script.pl\*(C'\fR.  Of course, it'll needto be executable first, so \f(CW\*(C`chmod 755 script.pl\*(C'\fR (under Unix)..PP(This start line assumes you have the \fBenv\fR program. You can also putdirectly the path to your perl executable, like in \f(CW\*(C`#!/usr/bin/perl\*(C'\fR)..PPFor more information, including instructions for other platforms such asWindows and Mac \s-1OS\s0, read perlrun..Sh "Safety net".IX Subsection "Safety net"Perl by default is very forgiving. In order to make it more robustit is recommended to start every program with the following lines:.PP.Vb 3\&    #!/usr/bin/perl\&    use strict;\&    use warnings;.Ve.PPThe two additional lines request from perl to catch various commonproblems in your code. They check different things so you need both. Apotential problem caught by \f(CW\*(C`use strict;\*(C'\fR will cause your code to stopimmediately when it is encountered, while \f(CW\*(C`use warnings;\*(C'\fR will merelygive a warning (like the command-line switch \fB\-w\fR) and let your code run.To read more about them check their respective manual pages at strictand warnings..Sh "Basic syntax overview".IX Subsection "Basic syntax overview"A Perl script or program consists of one or more statements.  Thesestatements are simply written in the script in a straightforwardfashion.  There is no need to have a \f(CW\*(C`main()\*(C'\fR function or anything ofthat kind..PPPerl statements end in a semi-colon:.PP.Vb 1\&    print "Hello, world";.Ve.PPComments start with a hash symbol and run to the end of the line.PP.Vb 1\&    # This is a comment.Ve.PPWhitespace is irrelevant:.PP.Vb 3\&    print\&        "Hello, world"\&        ;.Ve.PP\&... except inside quoted strings:.PP.Vb 3\&    # this would print with a linebreak in the middle\&    print "Hello\&    world";.Ve.PPDouble quotes or single quotes may be used around literal strings:.PP.Vb 2\&    print "Hello, world";\&    print \*(AqHello, world\*(Aq;.Ve.PPHowever, only double quotes \*(L"interpolate\*(R" variables and specialcharacters such as newlines (\f(CW\*(C`\en\*(C'\fR):.PP.Vb 2\&    print "Hello, $name\en";     # works fine\&    print \*(AqHello, $name\en\*(Aq;     # prints $name\en literally.Ve.PPNumbers don't need quotes around them:.PP.Vb 1\&    print 42;.Ve.PPYou can use parentheses for functions' arguments or omit themaccording to your personal taste.  They are only requiredoccasionally to clarify issues of precedence..PP.Vb 2\&    print("Hello, world\en");\&    print "Hello, world\en";.Ve.PPMore detailed information about Perl syntax can be found in perlsyn..Sh "Perl variable types".IX Subsection "Perl variable types"Perl has three main variable types: scalars, arrays, and hashes..IP "Scalars" 4.IX Item "Scalars"A scalar represents a single value:.Sp.Vb 2\&    my $animal = "camel";\&    my $answer = 42;.Ve.SpScalar values can be strings, integers or floating point numbers, and Perlwill automatically convert between them as required.  There is no needto pre-declare your variable types, but you have to declare them usingthe \f(CW\*(C`my\*(C'\fR keyword the first time you use them. (This is one of therequirements of \f(CW\*(C`use strict;\*(C'\fR.).SpScalar values can be used in various ways:.Sp.Vb 3\&    print $animal;\&    print "The animal is $animal\en";\&    print "The square of $answer is ", $answer * $answer, "\en";.Ve.SpThere are a number of \*(L"magic\*(R" scalars with names that look likepunctuation or line noise.  These special variables are used for allkinds of purposes, and are documented in perlvar.  The only one youneed to know about for now is \f(CW$_\fR which is the \*(L"default variable\*(R".It's used as the default argument to a number of functions in Perl, andit's set implicitly by certain looping constructs..Sp.Vb 1\&    print;          # prints contents of $_ by default.Ve.IP "Arrays" 4.IX Item "Arrays"An array represents a list of values:.Sp.Vb 3\&    my @animals = ("camel", "llama", "owl");\&    my @numbers = (23, 42, 69);\&    my @mixed   = ("camel", 42, 1.23);.Ve.SpArrays are zero-indexed.  Here's how you get at elements in an array:.Sp.Vb 2\&    print $animals[0];              # prints "camel"\&    print $animals[1];              # prints "llama".Ve.SpThe special variable \f(CW$#array\fR tells you the index of the last elementof an array:.Sp.Vb 1\&    print $mixed[$#mixed];       # last element, prints 1.23.Ve.SpYou might be tempted to use \f(CW\*(C`$#array + 1\*(C'\fR to tell you how many items thereare in an array.  Don't bother.  As it happens, using \f(CW@array\fR where Perlexpects to find a scalar value (\*(L"in scalar context\*(R") will give you the numberof elements in the array:.Sp.Vb 1\&    if (@animals < 5) { ... }.Ve.SpThe elements we're getting from the array start with a \f(CW\*(C`$\*(C'\fR becausewe're getting just a single value out of the array \*(-- you ask for a scalar,you get a scalar..SpTo get multiple values from an array:.Sp.Vb 3\&    @animals[0,1];                  # gives ("camel", "llama");\&    @animals[0..2];                 # gives ("camel", "llama", "owl");\&    @animals[1..$#animals];         # gives all except the first element.Ve.SpThis is called an \*(L"array slice\*(R"..SpYou can do various useful things to lists:.Sp.Vb 2\&    my @sorted    = sort @animals;\&    my @backwards = reverse @numbers;.Ve.SpThere are a couple of special arrays too, such as \f(CW@ARGV\fR (the commandline arguments to your script) and \f(CW@_\fR (the arguments passed to asubroutine).  These are documented in perlvar..IP "Hashes" 4.IX Item "Hashes"A hash represents a set of key/value pairs:.Sp.Vb 1\&    my %fruit_color = ("apple", "red", "banana", "yellow");.Ve.SpYou can use whitespace and the \f(CW\*(C`=>\*(C'\fR operator to lay them out morenicely:.Sp.Vb 4\&    my %fruit_color = (\&        apple  => "red",\&        banana => "yellow",\&    );.Ve.SpTo get at hash elements:.Sp.Vb 1\&    $fruit_color{"apple"};           # gives "red".Ve.SpYou can get at lists of keys and values with \f(CW\*(C`keys()\*(C'\fR and\&\f(CW\*(C`values()\*(C'\fR..Sp.Vb 2\&    my @fruits = keys %fruit_colors;\&    my @colors = values %fruit_colors;.Ve.SpHashes have no particular internal order, though you can sort the keysand loop through them..SpJust like special scalars and arrays, there are also special hashes.The most well known of these is \f(CW%ENV\fR which contains environmentvariables.  Read all about it (and other special variables) inperlvar..PPScalars, arrays and hashes are documented more fully in perldata..PPMore complex data types can be constructed using references, which allowyou to build lists and hashes within lists and hashes..PPA reference is a scalar value and can refer to any other Perl datatype. So by storing a reference as the value of an array or hashelement, you can easily create lists and hashes within lists andhashes. The following example shows a 2 level hash of hashstructure using anonymous hash references..PP.Vb 10\&    my $variables = {\&        scalar  =>  {\&                     description => "single item",\&                     sigil => \*(Aq$\*(Aq,\&                    },\&        array   =>  {\&                     description => "ordered list of items",\&                     sigil => \*(Aq@\*(Aq,\&                    },\&        hash    =>  {\&                     description => "key/value pairs",\&                     sigil => \*(Aq%\*(Aq,\&                    },\&    };

⌨️ 快捷键说明

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