Query: data::peek
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
Peek(3pm) User Contributed Perl Documentation Peek(3pm)NAMEData::Peek - A collection of low-level debug facilitiesSYNOPSISuse Data::Peek; print DDumper \%hash; # Same syntax as Data::Dumper DTidy { ref => $ref }; print DPeek $var; my ($pv, $iv, $nv, $rv, $magic) = DDual ($var [, 1]); print DPeek for DDual ($!, 1); print DDisplay ("ab cx{20ac} def "); print DHexDump ("ab cx{20ac} def "); my $dump = DDump $var; my %hash = DDump @list; DDump \%hash; my %hash = DDump (\%hash, 5); # dig 5 levels deep my $dump; open my $fh, ">", $dump; DDump_IO ($fh, \%hash, 6); close $fh; print $dump; # Imports use Data::Peek qw( :tidy VNR DGrow triplevar ); my $x = ""; DGrow ($x, 10000); my $tv = triplevar ("N{GREEK SMALL LETTER PI}", 3, "3.1415"); DDsort ("R"); DDumper [ $x ]; # use of :tidy make DDumper behave as DTidyDESCRIPTIONData::Peek started off as "DDumper" being a wrapper module over Data::Dumper, but grew out to be a set of low-level data introspection utilities that no other module provided yet, using the lowest level of the perl internals API as possible. DDumper ($var, ...) Not liking the default output of Data::Dumper, and always feeling the need to set "$Data::Dumper::Sortkeys = 1;", and not liking any of the default layouts, this function is just a wrapper around Data::Dumper::Dumper with everything set as I like it. $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; If "Data::Peek" is "use"d with import argument ":tidy", the result is formatted according to Perl::Tidy, see DTidy below, otherwise the result is further beautified to meet my needs: * quotation of hash keys has been removed (with the disadvantage that the output might not be parseable again). * arrows for hashes are aligned at 16 (longer keys don't align) * closing braces and brackets are now correctly aligned In void context, "DDumper ()" warn ()'s. Example $ perl -MDP -e'DDumper { ape => 1, foo => "egg", bar => [ 2, "baz", undef ]};' { ape => 1, bar => [ 2, 'baz', undef ], foo => 'egg' }; DTidy ($var, ...) "DTidy" is an alternative to "DDumper", where the output of "DDumper" is formatted using "Perl::Tidy" (if available) according to your ".perltidyrc" instead of the default behavior, maybe somewhat like (YMMV): $ perl -MDP=:tidy -we'DDumper { ape => 1, foo => "egg", bar => [ 2, "baz", undef ]};' { 'ape' => 1, 'bar' => [2, 'baz', undef], 'foo' => 'egg' } If "Data::Peek" is "use"d with import argument ":tidy", this is the default output method for "DDumper". If Perl::Tidy is not available, "DTidy" will fallback to "DDumper". This idea was shamelessly copied from John McNamara's Data::Dumper::Perltidy. DDsort ( 0 | 1 | R | V | VR | VN | VNR ) Set the hash sort algorithm for DDumper. The default is to sort by key value. 0 - Do not sort 1 - Sort by key R - Reverse sort by key V - Sort by value VR - Reverse sort by value VN - Sort by value numerical VNR - Reverse sort by value numerical These can also be passed to import: $ perl -MDP=VNR -we'DDumper { foo => 1, bar => 2, zap => 3, gum => 13 }' { gum => 13, zap => 3, bar => 2, foo => 1 }; $ perl -MDP=V -we'DDumper { foo => 1, bar => 2, zap => 3, gum => 13 }' { foo => 1, gum => 13, bar => 2, zap => 3 }; DPeek DPeek ($var) Playing with "sv_dump ()", I found "Perl_sv_peek ()", and it might be very useful for simple checks. If $var is omitted, uses $_. Example print DPeek "abcx{0a}dex{20ac}fg"; PV("abc de342202254fg"