From 229ea430763da51e5a4e4d82c72994cea4a99146 Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand" Date: Sun, 14 Feb 2010 16:33:42 +0100 Subject: [PATCH] Use warn () instead of print STDERR --- ChangeLog | 1 + Peek.pm | 6 +++--- Peek.xs | 4 ++-- t/10_DDumper.t | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index db1479a..89690a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Use $Data::Dumper::Quotekeys = 0; instead of removing the quotes myself * Put first hash element after opening lonely brace * Upped copyright to 2010 + * Use warn () instead of print STDERR 2009-11-09 0.29 - H.Merijn Brand diff --git a/Peek.pm b/Peek.pm index 75458bb..69d3720 100644 --- a/Peek.pm +++ b/Peek.pm @@ -82,7 +82,7 @@ sub DDumper $s =~ s/^(\s*[{[]) *\n *(?=\S)(?![{[])/$1 /gm; $s =~ s/^(\s+)/$1$1/gm; - defined wantarray or print STDERR $s; + defined wantarray or warn $s; return $s; } # DDumper @@ -163,7 +163,7 @@ sub DDump ($;$) defined wantarray and return $dump; - print STDERR $dump; + warn $dump; } # DDump "Indent"; @@ -225,7 +225,7 @@ And the result is further beautified to meet my needs: * arrows for hashes are aligned at 16 (longer keys don't align) * closing braces and brackets are now correctly aligned -In void context, C prints to STDERR. +In void context, C warn ()'s. Example diff --git a/Peek.xs b/Peek.xs index fef9cc1..f0dfa7d 100644 --- a/Peek.xs +++ b/Peek.xs @@ -58,7 +58,7 @@ SV *_DPeek (pTHX_ int items, SV *sv) void _Dump_Dual (pTHX_ SV *sv, SV *pv, SV *iv, SV *nv, SV *rv) { #ifndef NO_SV_PEEK - (void)fprintf (stderr, "%s\n PV: %s\n IV: %s\n NV: %s\n RV: %s\n", + warn ("%s\n PV: %s\n IV: %s\n NV: %s\n RV: %s\n", sv_peek (sv), sv_peek (pv), sv_peek (iv), sv_peek (nv), sv_peek (rv)); #endif } /* _Dump_Dual */ @@ -71,7 +71,7 @@ DPeek (...) PPCODE: I32 gimme = GIMME_V; ST (0) = _DPeek (aTHX_ items, ST (0)); - if (gimme == G_VOID) (void)fprintf (stderr, "%s\n", SvPVX (ST (0))); + if (gimme == G_VOID) warn ("%s\n", SvPVX (ST (0))); XSRETURN (1); /* XS DPeek */ diff --git a/t/10_DDumper.t b/t/10_DDumper.t index 182a5e0..f28c09c 100644 --- a/t/10_DDumper.t +++ b/t/10_DDumper.t @@ -31,7 +31,7 @@ while () { } if ($re) { like ($dump, qr{$exp}ms, ".. content $re"); - $1 and print STDERR "# '$1' (", length ($1), ")\n"; + $1 and diag "# '$1' (", length ($1), ")\n"; } else { is ($dump, $exp, ".. content"); -- 2.11.4.GIT