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

📄 storable.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 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 "Storable 3".TH Storable 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"Storable \- persistence for Perl data structures.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 3\& use Storable;\& store \e%table, \*(Aqfile\*(Aq;\& $hashref = retrieve(\*(Aqfile\*(Aq);\&\& use Storable qw(nstore store_fd nstore_fd freeze thaw dclone);\&\& # Network order\& nstore \e%table, \*(Aqfile\*(Aq;\& $hashref = retrieve(\*(Aqfile\*(Aq);   # There is NO nretrieve()\&\& # Storing to and retrieving from an already opened file\& store_fd \e@array, \e*STDOUT;\& nstore_fd \e%table, \e*STDOUT;\& $aryref = fd_retrieve(\e*SOCKET);\& $hashref = fd_retrieve(\e*SOCKET);\&\& # Serializing to memory\& $serialized = freeze \e%table;\& %table_clone = %{ thaw($serialized) };\&\& # Deep (recursive) cloning\& $cloneref = dclone($ref);\&\& # Advisory locking\& use Storable qw(lock_store lock_nstore lock_retrieve)\& lock_store \e%table, \*(Aqfile\*(Aq;\& lock_nstore \e%table, \*(Aqfile\*(Aq;\& $hashref = lock_retrieve(\*(Aqfile\*(Aq);.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"The Storable package brings persistence to your Perl data structurescontaining \s-1SCALAR\s0, \s-1ARRAY\s0, \s-1HASH\s0 or \s-1REF\s0 objects, i.e. anything that can beconveniently stored to disk and retrieved at a later time..PPIt can be used in the regular procedural way by calling \f(CW\*(C`store\*(C'\fR witha reference to the object to be stored, along with the file name wherethe image should be written..PPThe routine returns \f(CW\*(C`undef\*(C'\fR for I/O problems or other internal error,a true value otherwise. Serious errors are propagated as a \f(CW\*(C`die\*(C'\fR exception..PPTo retrieve data stored to disk, use \f(CW\*(C`retrieve\*(C'\fR with a file name.The objects stored into that file are recreated into memory for you,and a \fIreference\fR to the root object is returned. In case an I/O erroroccurs while reading, \f(CW\*(C`undef\*(C'\fR is returned instead. Other seriouserrors are propagated via \f(CW\*(C`die\*(C'\fR..PPSince storage is performed recursively, you might want to stuff referencesto objects that share a lot of common data into a single array or hashtable, and then store that object. That way, when you retrieve back thewhole thing, the objects will continue to share what they originally shared..PPAt the cost of a slight header overhead, you may store to an alreadyopened file descriptor using the \f(CW\*(C`store_fd\*(C'\fR routine, and retrievefrom a file via \f(CW\*(C`fd_retrieve\*(C'\fR. Those names aren't imported by default,so you will have to do that explicitly if you need those routines.The file descriptor you supply must be already opened, for readif you're going to retrieve and for write if you wish to store..PP.Vb 2\&        store_fd(\e%table, *STDOUT) || die "can\*(Aqt store to stdout\en";\&        $hashref = fd_retrieve(*STDIN);.Ve.PPYou can also store data in network order to allow easy sharing acrossmultiple platforms, or when storing on a socket known to be remotelyconnected. The routines to call have an initial \f(CW\*(C`n\*(C'\fR prefix for \fInetwork\fR,as in \f(CW\*(C`nstore\*(C'\fR and \f(CW\*(C`nstore_fd\*(C'\fR. At retrieval time, your data will becorrectly restored so you don't have to know whether you're restoringfrom native or network ordered data.  Double values are stored stringifiedto ensure portability as well, at the slight risk of loosing some precisionin the last decimals..PPWhen using \f(CW\*(C`fd_retrieve\*(C'\fR, objects are retrieved in sequence, oneobject (i.e. one recursive tree) per associated \f(CW\*(C`store_fd\*(C'\fR..PPIf you're more from the object-oriented camp, you can inherit fromStorable and directly store your objects by invoking \f(CW\*(C`store\*(C'\fR asa method. The fact that the root of the to-be-stored tree is ablessed reference (i.e. an object) is special-cased so that theretrieve does not provide a reference to that object but rather theblessed object reference itself. (Otherwise, you'd get a referenceto that blessed object)..SH "MEMORY STORE".IX Header "MEMORY STORE"The Storable engine can also store data into a Perl scalar instead, tolater retrieve them. This is mainly used to freeze a complex structure insome safe compact memory place (where it can possibly be sent to anotherprocess via some \s-1IPC\s0, since freezing the structure also serializes it ineffect). Later on, and maybe somewhere else, you can thaw the Perl scalarout and recreate the original complex structure in memory..PPSurprisingly, the routines to be called are named \f(CW\*(C`freeze\*(C'\fR and \f(CW\*(C`thaw\*(C'\fR.If you wish to send out the frozen scalar to another machine, use\&\f(CW\*(C`nfreeze\*(C'\fR instead to get a portable image..PPNote that freezing an object structure and immediately thawing itactually achieves a deep cloning of that structure:.PP.Vb 1\&    dclone(.) = thaw(freeze(.)).Ve.PPStorable provides you with a \f(CW\*(C`dclone\*(C'\fR interface which does not createthat intermediary scalar but instead freezes the structure in someinternal memory space and then immediately thaws it out..SH "ADVISORY LOCKING".IX Header "ADVISORY LOCKING"The \f(CW\*(C`lock_store\*(C'\fR and \f(CW\*(C`lock_nstore\*(C'\fR routine are equivalent to\&\f(CW\*(C`store\*(C'\fR and \f(CW\*(C`nstore\*(C'\fR, except that they get an exclusive lock onthe file before writing.  Likewise, \f(CW\*(C`lock_retrieve\*(C'\fR does the sameas \f(CW\*(C`retrieve\*(C'\fR, but also gets a shared lock on the file before reading..PPAs with any advisory locking scheme, the protection only works if yousystematically use \f(CW\*(C`lock_store\*(C'\fR and \f(CW\*(C`lock_retrieve\*(C'\fR.  If one side ofyour application uses \f(CW\*(C`store\*(C'\fR whilst the other uses \f(CW\*(C`lock_retrieve\*(C'\fR,you will get no protection at all..PPThe internal advisory locking is implemented using Perl's \fIflock()\fRroutine.  If your system does not support any form of \fIflock()\fR, or ifyou share your files across \s-1NFS\s0, you might wish to use other formsof locking by using modules such as LockFile::Simple which lock afile using a filesystem entry, instead of locking the file descriptor..SH "SPEED".IX Header "SPEED"The heart of Storable is written in C for decent speed. Extra low-leveloptimizations have been made when manipulating perl internals, tosacrifice encapsulation for the benefit of greater speed..SH "CANONICAL REPRESENTATION".IX Header "CANONICAL REPRESENTATION"Normally, Storable stores elements of hashes in the order they arestored internally by Perl, i.e. pseudo-randomly.  If you set\&\f(CW$Storable::canonical\fR to some \f(CW\*(C`TRUE\*(C'\fR value, Storable will storehashes with the elements sorted by their key.  This allows you tocompare data structures by comparing their frozen representations (oreven the compressed frozen representations), which can be useful forcreating lookup tables for complicated queries..PPCanonical order does not imply network order; those are two orthogonalsettings..SH "CODE REFERENCES".IX Header "CODE REFERENCES"Since Storable version 2.05, \s-1CODE\s0 references may be serialized withthe help of B::Deparse. To enable this feature, set\&\f(CW$Storable::Deparse\fR to a true value. To enable deserialization,\&\f(CW$Storable::Eval\fR should be set to a true value. Be aware that

⌨️ 快捷键说明

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