From 75eac067b9c258b0c8fbbf7d9907ccff922e4270 Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand" Date: Wed, 8 Oct 2008 09:12:29 +0200 Subject: [PATCH] Default argument for DPeek is $_ --- ChangeLog | 5 +++++ Peek.pm | 26 ++++++++++++++++---------- Peek.xs | 8 +++----- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30a4c86..95c07fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-10-08 0.20 - H.Merijn Brand + + * Renamed DDumper to Data::Peek + * Default argument for DPeek is $_ + 2008-10-07 0.16 - H.Merijn Brand * Allocated length for PV's depends on arch (upped test to 8) diff --git a/Peek.pm b/Peek.pm index 5b0f721..9775221 100644 --- a/Peek.pm +++ b/Peek.pm @@ -125,9 +125,9 @@ Data::Peek - A collection of low-level debug facilities print DDumper \%hash; # Same syntax as Data::Dumper - my ($pv, $iv, $nv, $rv, $magic) = DDual ($var [, 1]); - print DPeek \$var; + my ($pv, $iv, $nv, $rv, $magic) = DDual ($var [, 1]); + print DPeek for DDual ($!, 1); my $dump = DDump $var; my %hash = DDump \@list; @@ -181,6 +181,19 @@ Example foo => 'egg' }; +=head2 DPeek + +=head2 DPeek ($var) + +Playing with C, I found C, and it might be +very useful for simple checks. If C<$var> is omitted, uses $_. + +Example + + print DPeek "abc\x{0a}de\x{20ac}fg"; + + PV("abc\nde\342\202\254fg"\0) [UTF8 "abc\nde\x{20ac}fg"] + =head2 DDual ($var [, $getmagic]) DDual will return the basic elements in a variable, guaranteeing that no @@ -192,16 +205,9 @@ The 5th element is an indicator if C<$var> has magic, which is B invoked in the returned values, unless explicitly asked for with a true optional second argument. -=head2 DPeek ($var) - -Playing with C, I found C, and it might be -very useful for simple checks. - Example - print DPeek "abc\x{0a}de\x{20ac}fg"; - - PV("abc\nde\342\202\254fg"\0) [UTF8 "abc\nde\x{20ac}fg"] + print DPeek for DDual ($!, 1); =head3 DDump ($var [, $dig_level]) diff --git a/Peek.xs b/Peek.xs index c85ea2b..a6f3476 100644 --- a/Peek.xs +++ b/Peek.xs @@ -47,12 +47,10 @@ SV *_DDump (SV *sv) MODULE = Data::Peek PACKAGE = Data::Peek void -DPeek (sv) - SV *sv - - PROTOTYPE: $ +DPeek (...) + PROTOTYPE: ;$ PPCODE: - ST (0) = newSVpv (Perl_sv_peek (aTHX_ sv), 0); + ST (0) = newSVpv (Perl_sv_peek (aTHX_ items ? ST (0) : DEFSV), 0); XSRETURN (1); /* XS DPeek */ -- 2.11.4.GIT