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

📄 data::dumper.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
always be parseable by \f(CW\*(C`eval\*(C'\fR..IP "\(bu" 4\&\f(CW$Data::Dumper::Freezer\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Freezer(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a method name, or to an empty string to disable the feature.Data::Dumper will invoke that method via the object before attempting tostringify it.  This method can alter the contents of the object (if, forinstance, it contains data allocated from C), and even rebless it in adifferent package.  The client is responsible for making sure the specifiedmethod can be called via the object, and that the object ends up containingonly perl data types after the method has been called.  Defaults to an emptystring..SpIf an object does not support the method specified (determined using\&\fIUNIVERSAL::can()\fR) then the call will be skipped.  If the method dies awarning will be generated..IP "\(bu" 4\&\f(CW$Data::Dumper::Toaster\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Toaster(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a method name, or to an empty string to disable the feature.Data::Dumper will emit a method call for any objects that are to be dumpedusing the syntax \f(CW\*(C`bless(DATA, CLASS)\->METHOD()\*(C'\fR.  Note that this means thatthe method specified will have to perform any modifications required on theobject (like creating new state within it, and/or reblessing it in adifferent package) and then return it.  The client is responsible for makingsure the method can be called via the object, and that it returns a validobject.  Defaults to an empty string..IP "\(bu" 4\&\f(CW$Data::Dumper::Deepcopy\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Deepcopy(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a boolean value to enable deep copies of structures.Cross-referencing will then only be done when absolutely essential(i.e., to break reference cycles).  Default is 0..IP "\(bu" 4\&\f(CW$Data::Dumper::Quotekeys\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Quotekeys(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a boolean value to control whether hash keys are quoted.A false value will avoid quoting hash keys when it looks like a simplestring.  Default is 1, which will always enclose hash keys in quotes..IP "\(bu" 4\&\f(CW$Data::Dumper::Bless\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Bless(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a string that specifies an alternative to the \f(CW\*(C`bless\*(C'\fRbuiltin operator used to create objects.  A function with the specifiedname should exist, and should accept the same arguments as the builtin.Default is \f(CW\*(C`bless\*(C'\fR..IP "\(bu" 4\&\f(CW$Data::Dumper::Pair\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Pair(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a string that specifies the separator between hash keysand values. To dump nested hash, array and scalar values to JavaScript,use: \f(CW\*(C`$Data::Dumper::Pair = \*(Aq : \*(Aq;\*(C'\fR. Implementing \f(CW\*(C`bless\*(C'\fR in JavaScriptis left as an exercise for the reader.A function with the specified name exists, and accepts the same argumentsas the builtin..SpDefault is: \f(CW\*(C` => \*(C'\fR..IP "\(bu" 4\&\f(CW$Data::Dumper::Maxdepth\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Maxdepth(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a positive integer that specifies the depth beyond whichwhich we don't venture into a structure.  Has no effect when\&\f(CW\*(C`Data::Dumper::Purity\*(C'\fR is set.  (Useful in debugger when we often don'twant to see more than enough).  Default is 0, which means there is no maximum depth..IP "\(bu" 4\&\f(CW$Data::Dumper::Useperl\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Useperl(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a boolean value which controls whether the pure Perlimplementation of \f(CW\*(C`Data::Dumper\*(C'\fR is used. The \f(CW\*(C`Data::Dumper\*(C'\fR module isa dual implementation, with almost all functionality written in bothpure Perl and also in \s-1XS\s0 ('C'). Since the \s-1XS\s0 version is much faster, itwill always be used if possible. This option lets you override thedefault behavior, usually for testing purposes only. Default is 0, whichmeans the \s-1XS\s0 implementation will be used if possible..IP "\(bu" 4\&\f(CW$Data::Dumper::Sortkeys\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Sortkeys(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a boolean value to control whether hash keys are dumped insorted order. A true value will cause the keys of all hashes to bedumped in Perl's default sort order. Can also be set to a subroutinereference which will be called for each hash that is dumped. In thiscase \f(CW\*(C`Data::Dumper\*(C'\fR will call the subroutine once for each hash,passing it the reference of the hash. The purpose of the subroutine isto return a reference to an array of the keys that will be dumped, inthe order that they should be dumped. Using this feature, you cancontrol both the order of the keys, and which keys are actually used. Inother words, this subroutine acts as a filter by which you can excludecertain keys from being dumped. Default is 0, which means that hash keysare not sorted..IP "\(bu" 4\&\f(CW$Data::Dumper::Deparse\fR  \fIor\fR  $\fI\s-1OBJ\s0\fR\->Deparse(\fI[\s-1NEWVAL\s0]\fR).SpCan be set to a boolean value to control whether code references areturned into perl source code. If set to a true value, \f(CW\*(C`B::Deparse\*(C'\fRwill be used to get the source of the code reference. Using this optionwill force using the Perl implementation of the dumper, since the fast\&\s-1XSUB\s0 implementation doesn't support it..SpCaution : use this option only if you know that your coderefs will beproperly reconstructed by \f(CW\*(C`B::Deparse\*(C'\fR..Sh "Exports".IX Subsection "Exports".IP "Dumper" 4.IX Item "Dumper".SH "EXAMPLES".IX Header "EXAMPLES"Run these code snippets to get a quick feel for the behavior of thismodule.  When you are through with these examples, you may want toadd or change the various configuration variables described above,to see their behavior.  (See the testsuite in the Data::Dumperdistribution for more examples.).PP.Vb 1\&    use Data::Dumper;\&\&    package Foo;\&    sub new {bless {\*(Aqa\*(Aq => 1, \*(Aqb\*(Aq => sub { return "foo" }}, $_[0]};\&\&    package Fuz;                       # a weird REF\-REF\-SCALAR object\&    sub new {bless \e($_ = \e \*(Aqfu\e\*(Aqz\*(Aq), $_[0]};\&\&    package main;\&    $foo = Foo\->new;\&    $fuz = Fuz\->new;\&    $boo = [ 1, [], "abcd", \e*foo,\&             {1 => \*(Aqa\*(Aq, 023 => \*(Aqb\*(Aq, 0x45 => \*(Aqc\*(Aq}, \&             \e\e"p\eq\e\*(Aqr", $foo, $fuz];\&\&    ########\&    # simple usage\&    ########\&\&    $bar = eval(Dumper($boo));\&    print($@) if $@;\&    print Dumper($boo), Dumper($bar);  # pretty print (no array indices)\&\&    $Data::Dumper::Terse = 1;          # don\*(Aqt output names where feasible\&    $Data::Dumper::Indent = 0;         # turn off all pretty print\&    print Dumper($boo), "\en";\&\&    $Data::Dumper::Indent = 1;         # mild pretty print\&    print Dumper($boo);\&\&    $Data::Dumper::Indent = 3;         # pretty print with array indices\&    print Dumper($boo);\&\&    $Data::Dumper::Useqq = 1;          # print strings in double quotes\&    print Dumper($boo);\&\&    $Data::Dumper::Pair = " : ";       # specify hash key/value separator\&    print Dumper($boo);\&\&\&    ########\&    # recursive structures\&    ########\&\&    @c = (\*(Aqc\*(Aq);\&    $c = \e@c;\&    $b = {};\&    $a = [1, $b, $c];\&    $b\->{a} = $a;\&    $b\->{b} = $a\->[1];\&    $b\->{c} = $a\->[2];\&    print Data::Dumper\->Dump([$a,$b,$c], [qw(a b c)]);\&\&\&    $Data::Dumper::Purity = 1;         # fill in the holes for eval\&    print Data::Dumper\->Dump([$a, $b], [qw(*a b)]); # print as @a\&    print Data::Dumper\->Dump([$b, $a], [qw(*b a)]); # print as %b\&\&\&    $Data::Dumper::Deepcopy = 1;       # avoid cross\-refs\&    print Data::Dumper\->Dump([$b, $a], [qw(*b a)]);\&\&\&    $Data::Dumper::Purity = 0;         # avoid cross\-refs\&    print Data::Dumper\->Dump([$b, $a], [qw(*b a)]);\&\&    ########\&    # deep structures\&    ########\&\&    $a = "pearl";\&    $b = [ $a ];\&    $c = { \*(Aqb\*(Aq => $b };\&    $d = [ $c ];\&    $e = { \*(Aqd\*(Aq => $d };\&    $f = { \*(Aqe\*(Aq => $e };\&    print Data::Dumper\->Dump([$f], [qw(f)]);\&\&    $Data::Dumper::Maxdepth = 3;       # no deeper than 3 refs down\&    print Data::Dumper\->Dump([$f], [qw(f)]);\&\&\&    ########\&    # object\-oriented usage\&    ########\&\&    $d = Data::Dumper\->new([$a,$b], [qw(a b)]);\&    $d\->Seen({\*(Aq*c\*(Aq => $c});            # stash a ref without printing it\&    $d\->Indent(3);\&    print $d\->Dump;\&    $d\->Reset\->Purity(0);              # empty the seen cache\&    print join "\-\-\-\-\en", $d\->Dump;\&\&\&    ########\&    # persistence\&    ########\&\&    package Foo;\&    sub new { bless { state => \*(Aqawake\*(Aq }, shift }\&    sub Freeze {\&        my $s = shift;\&        print STDERR "preparing to sleep\en";\&        $s\->{state} = \*(Aqasleep\*(Aq;\&        return bless $s, \*(AqFoo::ZZZ\*(Aq;\&    }\&\&    package Foo::ZZZ;\&    sub Thaw {\&        my $s = shift;\&        print STDERR "waking up\en";\&        $s\->{state} = \*(Aqawake\*(Aq;\&        return bless $s, \*(AqFoo\*(Aq;\&    }\&\&    package Foo;\&    use Data::Dumper;\&    $a = Foo\->new;\&    $b = Data::Dumper\->new([$a], [\*(Aqc\*(Aq]);\&    $b\->Freezer(\*(AqFreeze\*(Aq);\&    $b\->Toaster(\*(AqThaw\*(Aq);\&    $c = $b\->Dump;\&    print $c;\&    $d = eval $c;\&    print Data::Dumper\->Dump([$d], [\*(Aqd\*(Aq]);\&\&\&    ########\&    # symbol substitution (useful for recreating CODE refs)\&    ########\&\&    sub foo { print "foo speaking\en" }\&    *other = \e&foo;\&    $bar = [ \e&other ];\&    $d = Data::Dumper\->new([\e&other,$bar],[\*(Aq*other\*(Aq,\*(Aqbar\*(Aq]);\&    $d\->Seen({ \*(Aq*foo\*(Aq => \e&foo });\&    print $d\->Dump;\&\&\&    ########\&    # sorting and filtering hash keys\&    ########\&\&    $Data::Dumper::Sortkeys = \e&my_filter;\&    my $foo = { map { (ord, "$_$_$_") } \*(AqI\*(Aq..\*(AqQ\*(Aq };\&    my $bar = { %$foo };\&    my $baz = { reverse %$foo };\&    print Dumper [ $foo, $bar, $baz ];\&\&    sub my_filter {\&        my ($hash) = @_;\&        # return an array ref containing the hash keys to dump\&        # in the order that you want them to be dumped\&        return [\&          # Sort the keys of %$foo in reverse numeric order\&            $hash eq $foo ? (sort {$b <=> $a} keys %$hash) :\&          # Only dump the odd number keys of %$bar\&            $hash eq $bar ? (grep {$_ % 2} keys %$hash) :\&          # Sort keys in default order for all other hashes\&            (sort keys %$hash)\&        ];\&    }.Ve.SH "BUGS".IX Header "BUGS"Due to limitations of Perl subroutine call semantics, you cannot pass anarray or hash.  Prepend it with a \f(CW\*(C`\e\*(C'\fR to pass its reference instead.  Thiswill be remedied in time, now that Perl has subroutine prototypes.For now, you need to use the extended usage form, and prepend thename with a \f(CW\*(C`*\*(C'\fR to output it as a hash or array..PP\&\f(CW\*(C`Data::Dumper\*(C'\fR cheats with \s-1CODE\s0 references.  If a code reference isencountered in the structure being processed (and if you haven't setthe \f(CW\*(C`Deparse\*(C'\fR flag), an anonymous subroutine thatcontains the string '\*(L"\s-1DUMMY\s0\*(R"' will be inserted in its place, and a warningwill be printed if \f(CW\*(C`Purity\*(C'\fR is set.  You can \f(CW\*(C`eval\*(C'\fR the result, but bearin mind that the anonymous sub that gets created is just a placeholder.Someday, perl will have a switch to cache-on-demand the stringrepresentation of a compiled piece of code, I hope.  If you have priorknowledge of all the code refs that your data structures are likelyto have, you can use the \f(CW\*(C`Seen\*(C'\fR method to pre-seed the internal referencetable and make the dumped output point to them, instead.  See \*(L"\s-1EXAMPLES\s0\*(R"above..PPThe \f(CW\*(C`Useqq\*(C'\fR and \f(CW\*(C`Deparse\*(C'\fR flags makes \fIDump()\fR run slower, since the\&\s-1XSUB\s0 implementation does not support them..PP\&\s-1SCALAR\s0 objects have the weirdest looking \f(CW\*(C`bless\*(C'\fR workaround..PPPure Perl version of \f(CW\*(C`Data::Dumper\*(C'\fR escapes \s-1UTF\-8\s0 strings correctlyonly in Perl 5.8.0 and later..Sh "\s-1NOTE\s0".IX Subsection "NOTE"Starting from Perl 5.8.1 different runs of Perl will have differentordering of hash keys.  The change was done for greater security,see \*(L"Algorithmic Complexity Attacks\*(R" in perlsec.  This means thatdifferent runs of Perl will have different Data::Dumper outputs ifthe data contains hashes.  If you need to have identical Data::Dumperoutputs from different runs of Perl, use the environment variable\&\s-1PERL_HASH_SEED\s0, see \*(L"\s-1PERL_HASH_SEED\s0\*(R" in perlrun.  Using this restoresthe old (platform-specific) ordering: an even prettier solution mightbe to use the \f(CW\*(C`Sortkeys\*(C'\fR filter of Data::Dumper..SH "AUTHOR".IX Header "AUTHOR"Gurusamy Sarathy        gsar@activestate.com.PPCopyright (c) 1996\-98 Gurusamy Sarathy. All rights reserved.This program is free software; you can redistribute it and/ormodify it under the same terms as Perl itself..SH "VERSION".IX Header "VERSION"Version 2.121  (Aug 24 2003).SH "SEE ALSO".IX Header "SEE ALSO"\&\fIperl\fR\|(1)

⌨️ 快捷键说明

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