X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDumpvalue.pm;h=109e2295af6d732a3220dd63fe3c06956efdf656;hb=2b37efcc2bc957549bbeb5c71adf3fced634e4c9;hp=427f57cc4257072469ff26398df65f745103815b;hpb=3b825e419da1c361eab06a1e6d287276c0aef241;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Dumpvalue.pm b/lib/Dumpvalue.pm index 427f57c..109e229 100644 --- a/lib/Dumpvalue.pm +++ b/lib/Dumpvalue.pm @@ -1,9 +1,10 @@ use 5.006_001; # for (defined ref) and $#$v and our package Dumpvalue; use strict; -our $VERSION = '1.00'; +our $VERSION = '1.11'; our(%address, $stab, @stab, %stab, %subs); +# documentation nits, handle complex data structures better by chromatic # translate control chars to ^X - Randal Schwartz # Modifications to print types by Peter Gordon v1.0 @@ -428,7 +429,14 @@ EOP sub scalarUsage { my $self = shift; - my $size = length($_[0]); + my $size; + if (UNIVERSAL::isa($_[0], 'ARRAY')) { + $size = $self->arrayUsage($_[0]); + } elsif (UNIVERSAL::isa($_[0], 'HASH')) { + $size = $self->hashUsage($_[0]); + } elsif (!ref($_[0])) { + $size = length($_[0]); + } $self->{TotalStrings} += $size; $self->{Strings}++; $size; @@ -484,6 +492,7 @@ Dumpvalue - provides screen dump of Perl data. $dumper->set(globPrint => 1); $dumper->dumpValue(\*::); $dumper->dumpvars('main'); + my $dump = $dumper->stringify($some_value); =head1 DESCRIPTION @@ -511,28 +520,28 @@ may be printed on one line. Whether to print contents of globs. -=item C +=item C Dump arrays holding contents of debugged files. -=item C +=item C Dump symbol tables of packages. -=item C +=item C Dump contents of "reused" addresses. -=item C, C, C +=item C, C, C Change style of string dump. Default value of C is C, one can enable either double-quotish dump, or single-quotish by setting it to C<"> or C<'>. By default, characters with high bit set are printed -I. +I. If C is set, they will be quoted. -=item C +=item C -I rudimentally per-package memory usage dump. If set, +rudimentally per-package memory usage dump. If set, C calculates total size of strings in variables in the package. =item unctrl @@ -570,10 +579,22 @@ method and set() method (which accept multiple arguments). $dumper->dumpValue($value); $dumper->dumpValue([$value1, $value2]); +Prints a dump to the currently selected filehandle. + =item dumpValues $dumper->dumpValues($value1, $value2); +Same as C< $dumper->dumpValue([$value1, $value2]); >. + +=item stringify + + my $dump = $dumper->stringify($value [,$noticks] ); + +Returns the dump of a single scalar without printing. If the second +argument is true, the return value does not contain enclosing ticks. +Does not handle data structures. + =item dumpvars $dumper->dumpvars('my_package'); @@ -595,7 +616,7 @@ given quote char. Possible values are C, C<'> and C<">. =item set_unctrl - $d->set_unctrl('"'); + $d->set_unctrl('unctrl'); Sets C option with checking for an invalid argument. Possible values are C and C.