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

📄 tie::file.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 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 "Tie::File 3".TH Tie::File 3 "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"Tie::File \- Access the lines of a disk file via a Perl array.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 2\&        # This file documents Tie::File version 0.97\&        use Tie::File;\&\&        tie @array, \*(AqTie::File\*(Aq, filename or die ...;\&\&        $array[13] = \*(Aqblah\*(Aq;     # line 13 of the file is now \*(Aqblah\*(Aq\&        print $array[42];        # display line 42 of the file\&\&        $n_recs = @array;        # how many records are in the file?\&        $#array \-= 2;            # chop two records off the end\&\&\&        for (@array) {\&          s/PERL/Perl/g;         # Replace PERL with Perl everywhere in the file\&        }\&\&        # These are just like regular push, pop, unshift, shift, and splice\&        # Except that they modify the file in the way you would expect\&\&        push @array, new recs...;\&        my $r1 = pop @array;\&        unshift @array, new recs...;\&        my $r2 = shift @array;\&        @old_recs = splice @array, 3, 7, new recs...;\&\&        untie @array;            # all finished.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"\&\f(CW\*(C`Tie::File\*(C'\fR represents a regular text file as a Perl array.  Eachelement in the array corresponds to a record in the file.  The firstline of the file is element 0 of the array; the second line is element1, and so on..PPThe file is \fInot\fR loaded into memory, so this will work even forgigantic files..PPChanges to the array are reflected in the file immediately..PPLazy people and beginners may now stop reading the manual..ie n .Sh """recsep""".el .Sh "\f(CWrecsep\fP".IX Subsection "recsep"What is a 'record'?  By default, the meaning is the same as for the\&\f(CW\*(C`<...>\*(C'\fR operator: It's a string terminated by \f(CW$/\fR, which isprobably \f(CW"\en"\fR.  (Minor exception: on \s-1DOS\s0 and Win32 systems, a\&'record' is a string terminated by \f(CW"\er\en"\fR.)  You may change thedefinition of \*(L"record\*(R" by supplying the \f(CW\*(C`recsep\*(C'\fR option in the \f(CW\*(C`tie\*(C'\fRcall:.PP.Vb 1\&        tie @array, \*(AqTie::File\*(Aq, $file, recsep => \*(Aqes\*(Aq;.Ve.PPThis says that records are delimited by the string \f(CW\*(C`es\*(C'\fR.  If the filecontained the following data:.PP.Vb 1\&        Curse these pesky flies!\en.Ve.PPthen the \f(CW@array\fR would appear to have four elements:.PP.Vb 4\&        "Curse th"\&        "e p"\&        "ky fli"\&        "!\en".Ve.PPAn undefined value is not permitted as a record separator.  Perl'sspecial \*(L"paragraph mode\*(R" semantics (a\*` la \f(CW\*(C`$/ = ""\*(C'\fR) are notemulated..PPRecords read from the tied array do not have the record separatorstring on the end; this is to allow.PP.Vb 1\&        $array[17] .= "extra";.Ve.PPto work as expected..PP(See \*(L"autochomp\*(R", below.)  Records stored into the array will havethe record separator string appended before they are written to thefile, if they don't have one already.  For example, if the recordseparator string is \f(CW"\en"\fR, then the following two lines do exactlythe same thing:.PP.Vb 2\&        $array[17] = "Cherry pie";\&        $array[17] = "Cherry pie\en";.Ve.PPThe result is that the contents of line 17 of the file will bereplaced with \*(L"Cherry pie\*(R"; a newline character will separate line 17from line 18.  This means that this code will do nothing:.PP.Vb 1\&        chomp $array[17];.Ve.PPBecause the \f(CW\*(C`chomp\*(C'\fRed value will have the separator reattached whenit is written back to the file.  There is no way to create a filewhose trailing record separator string is missing..PPInserting records that \fIcontain\fR the record separator string is notsupported by this module.  It will probably produce a reasonableresult, but what this result will be may change in a future version.Use 'splice' to insert records or to replace one record with several..ie n .Sh """autochomp""".el .Sh "\f(CWautochomp\fP".IX Subsection "autochomp"Normally, array elements have the record separator removed, so that ifthe file contains the text.PP.Vb 3\&        Gold\&        Frankincense\&        Myrrh.Ve.PPthe tied array will appear to contain \f(CW\*(C`("Gold", "Frankincense","Myrrh")\*(C'\fR.  If you set \f(CW\*(C`autochomp\*(C'\fR to a false value, the recordseparator will not be removed.  If the file above was tied with.PP.Vb 1\&        tie @gifts, "Tie::File", $gifts, autochomp => 0;.Ve.PPthen the array \f(CW@gifts\fR would appear to contain \f(CW\*(C`("Gold\en","Frankincense\en", "Myrrh\en")\*(C'\fR, or (on Win32 systems) \f(CW\*(C`("Gold\er\en","Frankincense\er\en", "Myrrh\er\en")\*(C'\fR..ie n .Sh """mode""".el .Sh "\f(CWmode\fP".IX Subsection "mode"Normally, the specified file will be opened for read and write access,and will be created if it does not exist.  (That is, the flags\&\f(CW\*(C`O_RDWR | O_CREAT\*(C'\fR are supplied in the \f(CW\*(C`open\*(C'\fR call.)  If you want tochange this, you may supply alternative flags in the \f(CW\*(C`mode\*(C'\fR option.See Fcntl for a listing of available flags.For example:.PP.Vb 3\&        # open the file if it exists, but fail if it does not exist\&        use Fcntl \*(AqO_RDWR\*(Aq;\&        tie @array, \*(AqTie::File\*(Aq, $file, mode => O_RDWR;\&\&        # create the file if it does not exist\&        use Fcntl \*(AqO_RDWR\*(Aq, \*(AqO_CREAT\*(Aq;\&        tie @array, \*(AqTie::File\*(Aq, $file, mode => O_RDWR | O_CREAT;\&\&        # open an existing file in read\-only mode\&        use Fcntl \*(AqO_RDONLY\*(Aq;\&        tie @array, \*(AqTie::File\*(Aq, $file, mode => O_RDONLY;.Ve.PPOpening the data file in write-only or append mode is not supported..ie n .Sh """memory""".el .Sh "\f(CWmemory\fP".IX Subsection "memory"This is an upper limit on the amount of memory that \f(CW\*(C`Tie::File\*(C'\fR willconsume at any time while managing the file.  This is used for twothings: managing the \fIread cache\fR and managing the \fIdeferred writebuffer\fR..PPRecords read in from the file are cached, to avoid having to re-readthem repeatedly.  If you read the same record twice, the first time itwill be stored in memory, and the second time it will be fetched fromthe \fIread cache\fR.  The amount of data in the read cache will notexceed the value you specified for \f(CW\*(C`memory\*(C'\fR.  If \f(CW\*(C`Tie::File\*(C'\fR wantsto cache a new record, but the read cache is full, it will make roomby expiring the least-recently visited records from the read cache..PPThe default memory limit is 2Mib.  You can adjust the maximum readcache size by supplying the \f(CW\*(C`memory\*(C'\fR option.  The argument is thedesired cache size, in bytes..PP.Vb 2\&        # I have a lot of memory, so use a large cache to speed up access\&        tie @array, \*(AqTie::File\*(Aq, $file, memory => 20_000_000;.Ve.PPSetting the memory limit to 0 will inhibit caching; records will befetched from disk every time you examine them..PPThe \f(CW\*(C`memory\*(C'\fR value is not an absolute or exact limit on the memoryused.  \f(CW\*(C`Tie::File\*(C'\fR objects contains some structures besides the readcache and the deferred write buffer, whose sizes are not chargedagainst \f(CW\*(C`memory\*(C'\fR..PPThe cache itself consumes about 310 bytes per cached record, so ifyour file has many short records, you may want to decrease the cachememory limit, or else the cache overhead may exceed the size of thecached data..ie n .Sh """dw_size""".el .Sh "\f(CWdw_size\fP".IX Subsection "dw_size"(This is an advanced feature.  Skip this section on first reading.).PPIf you use deferred writing (See \*(L"Deferred Writing\*(R", below) thendata you write into the array will not be written directly to thefile; instead, it will be saved in the \fIdeferred write buffer\fR to bewritten out later.  Data in the deferred write buffer is also chargedagainst the memory limit you set with the \f(CW\*(C`memory\*(C'\fR option..PPYou may set the \f(CW\*(C`dw_size\*(C'\fR option to limit the amount of data that canbe saved in the deferred write buffer.  This limit may not exceed thetotal memory limit.  For example, if you set \f(CW\*(C`dw_size\*(C'\fR to 1000 and\&\f(CW\*(C`memory\*(C'\fR to 2500, that means that no more than 1000 bytes of deferredwrites will be saved up.  The space available for the read cache willvary, but it will always be at least 1500 bytes (if the deferred writebuffer is full) and it could grow as large as 2500 bytes (if thedeferred write buffer is empty.).PPIf you don't specify a \f(CW\*(C`dw_size\*(C'\fR, it defaults to the entire memorylimit..Sh "Option Format".IX Subsection "Option Format"\&\f(CW\*(C`\-mode\*(C'\fR is a synonym for \f(CW\*(C`mode\*(C'\fR.  \f(CW\*(C`\-recsep\*(C'\fR is a synonym for\&\f(CW\*(C`recsep\*(C'\fR.  \f(CW\*(C`\-memory\*(C'\fR is a synonym for \f(CW\*(C`memory\*(C'\fR.  You get theidea..SH "Public Methods".IX Header "Public Methods"The \f(CW\*(C`tie\*(C'\fR call returns an object, say \f(CW$o\fR.  You may call.PP.Vb 2\&        $rec = $o\->FETCH($n);\&        $o\->STORE($n, $rec);.Ve.PPto fetch or store the record at line \f(CW$n\fR, respectively; similarlythe other tied array methods.  (See perltie for details.)  You mayalso call the following methods on this object:.ie n .Sh """flock""".el .Sh "\f(CWflock\fP".IX Subsection "flock".Vb 1\&        $o\->flock(MODE).Ve.PPwill lock the tied file.  \f(CW\*(C`MODE\*(C'\fR has the same meaning as the secondargument to the Perl built-in \f(CW\*(C`flock\*(C'\fR function; for example\&\f(CW\*(C`LOCK_SH\*(C'\fR or \f(CW\*(C`LOCK_EX | LOCK_NB\*(C'\fR.  (These constants are provided bythe \f(CW\*(C`use Fcntl \*(Aq:flock\*(Aq\*(C'\fR declaration.).PP\&\f(CW\*(C`MODE\*(C'\fR is optional; the default is \f(CW\*(C`LOCK_EX\*(C'\fR..PP

⌨️ 快捷键说明

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