Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Data::Dump.3pm
CommitLineData
3fea05b9 1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Data::Dump 3"
132.TH Data::Dump 3 "2009-07-26" "perl v5.8.7" "User Contributed Perl Documentation"
133.SH "NAME"
134Data::Dump \- Pretty printing of data structures
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use Data::Dump qw(dump ddx);
139.Ve
140.PP
141.Vb 2
142\& $str = dump(@list);
143\& @copy_of_list = eval $str;
144.Ve
145.PP
146.Vb 2
147\& # or use it for easy debug printout
148\& ddx localtime;
149.Ve
150.SH "DESCRIPTION"
151.IX Header "DESCRIPTION"
152This module provide functions that takes a list of values as their
153argument and produces a string as its result. The string contains
154Perl code that, when \f(CW\*(C`eval\*(C'\fRed, produces a deep copy of the original
155arguments.
156.PP
157The main feature of the module is that it strives to produce output
158that is easy to read. Example:
159.PP
160.Vb 2
161\& @a = (1, [2, 3], {4 => 5});
162\& dump(@a);
163.Ve
164.PP
165Produces:
166.PP
167.Vb 1
168\& (1, [2, 3], { 4 => 5 })
169.Ve
170.PP
171If you dump just a little data, it is output on a single line. If
172you dump data that is more complex or there is a lot of it, line breaks
173are automatically added to keep it easy to read.
174.PP
175The following functions are provided (only the dd* functions are exported by default):
176.IP "dump( ... )" 4
177.IX Item "dump( ... )"
178.PD 0
179.IP "pp( ... )" 4
180.IX Item "pp( ... )"
181.PD
182Returns a string containing a Perl expression. If you pass this
183string to Perl's built-in \fIeval()\fR function it should return a copy of
184the arguments you passed to \fIdump()\fR.
185.Sp
186If you call the function with multiple arguments then the output will
187be wrapped in parenthesis \*(L"( ..., ... )\*(R". If you call the function with a
188single argument the output will not have the wrapping. If you call the function with
189a single scalar (non\-reference) argument it will just return the
190scalar quoted if needed, but never break it into multiple lines. If you
191pass multiple arguments or references to arrays of hashes then the
192return value might contain line breaks to format it for easier
193reading. The returned string will never be \*(L"\en\*(R" terminated, even if
194contains multiple lines. This allows code like this to place the
195semicolon in the expected place:
196.Sp
197.Vb 1
198\& print '$obj = ', dump($obj), ";\en";
199.Ve
200.Sp
201If \fIdump()\fR is called in void context, then the dump is printed on
202\&\s-1STDERR\s0 and then \*(L"\en\*(R" terminated. You might find this useful for quick
203debug printouts, but the dd*() functions might be better alternatives
204for this.
205.Sp
206There is no difference between \fIdump()\fR and \fIpp()\fR, except that \fIdump()\fR
207shares its name with a not-so-useful perl builtin. Because of this
208some might want to avoid using that name.
209.ie n .IP "quote( $string )" 4
210.el .IP "quote( \f(CW$string\fR )" 4
211.IX Item "quote( $string )"
212Returns a quoted version of the provided string.
213.Sp
214It differs from \f(CW\*(C`dump($string)\*(C'\fR in that it will quote even numbers and
215not try to come up with clever expressions that might shorten the
216output.
217.IP "dd( ... )" 4
218.IX Item "dd( ... )"
219.PD 0
220.IP "ddx( ... )" 4
221.IX Item "ddx( ... )"
222.PD
223These functions will call \fIdump()\fR on their argument and print the
224result to \s-1STDOUT\s0 (actually, it's the currently selected output handle, but
225\&\s-1STDOUT\s0 is the default for that).
226.Sp
227The difference between them is only that \fIddx()\fR will prefix the lines
228it prints with \*(L"# \*(R" and mark the first line with the file and line
229number where it was called. This is meant to be useful for debug
230printouts of state within programs.
231.SH "LIMITATIONS"
232.IX Header "LIMITATIONS"
233Code references will be displayed as simply 'sub { \*(L"???\*(R" }' when
234dumped. Thus, \f(CW\*(C`eval\*(C'\fRing them will not reproduce the original routine.
235.PP
236If you forget to explicitly import the \f(CW\*(C`dump\*(C'\fR function, your code will
237core dump. That's because you just called the builtin \f(CW\*(C`dump\*(C'\fR function
238by accident, which intentionally dumps core. Because of this you can
239also import the same function as \f(CW\*(C`pp\*(C'\fR, mnemonic for \*(L"pretty\-print\*(R".
240.SH "HISTORY"
241.IX Header "HISTORY"
242The \f(CW\*(C`Data::Dump\*(C'\fR module grew out of frustration with Sarathy's
243in-most-cases-excellent \f(CW\*(C`Data::Dumper\*(C'\fR. Basic ideas and some code
244are shared with Sarathy's module.
245.PP
246The \f(CW\*(C`Data::Dump\*(C'\fR module provides a much simpler interface than
247\&\f(CW\*(C`Data::Dumper\*(C'\fR. No \s-1OO\s0 interface is available and there are no
248configuration options to worry about (yet :\-). The other benefit is
249that the dump produced does not try to set any variables. It only
250returns what is needed to produce a copy of the arguments. This means
251that \f(CW\*(C`dump("foo")\*(C'\fR simply returns \f(CW"foo"\fR, and \f(CW\*(C`dump(1..5)\*(C'\fR simply
252returns \f(CW\*(C`(1, 2, 3, 4, 5)\*(C'\fR.
253.SH "SEE ALSO"
254.IX Header "SEE ALSO"
255Data::Dumper, Storable
256.SH "AUTHORS"
257.IX Header "AUTHORS"
258The \f(CW\*(C`Data::Dump\*(C'\fR module is written by Gisle Aas <gisle@aas.no>, based
259on \f(CW\*(C`Data::Dumper\*(C'\fR by Gurusamy Sarathy <gsar@umich.edu>.
260.PP
261.Vb 2
262\& Copyright 1998\-2000,2003\-2004,2008 Gisle Aas.
263\& Copyright 1996\-1998 Gurusamy Sarathy.
264.Ve
265.PP
266This library is free software; you can redistribute it and/or
267modify it under the same terms as Perl itself.