Dropping in after a reference to this was posted on the perl5 mailing list.

The redirection to STDERR was exactly the reason why I wrote Data::Peek

use Data::Peek; my %hash = ( boo => [ 1..3 ], blah => "ab\nc\x{20ac}" ); my $dump; open my $fh, ">", \$dump; DDump_IO ($fh, \%hash, 6); close $fh; print $dump;

This uses perl internals to dump data structures, instead of using perl code to traverse and dump.

SV = RV(0x8804c8) at 0x8804b8 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x880530 SV = PVHV(0x866db0) at 0x880530 REFCNT = 2 FLAGS = (PADMY,SHAREKEYS) ARRAY = 0x86ef70 (0:7, 2:1) hash quality = 62.5% KEYS = 2 FILL = 1 MAX = 7 RITER = -1 EITER = 0x0 Elt "blah" HASH = 0x4566b599 SV = PV(0x85a098) at 0x8804a0 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x86aa10 "ab\nc\342\202\254"\0 [UTF8 "ab\nc\x{20ac}"] CUR = 7 LEN = 8 Elt "boo" HASH = 0x73a487c9 SV = RV(0x85c150) at 0x85c140 REFCNT = 1 FLAGS = (ROK) RV = 0x85c2f0 SV = PVAV(0x85d490) at 0x85c2f0 REFCNT = 1 FLAGS = () ARRAY = 0x86e970 FILL = 2 MAX = 2 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = IV(0x85c4b0) at 0x85c4b8 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 Elt No. 1 SV = IV(0x880588) at 0x880590 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 2 Elt No. 2 SV = IV(0x880570) at 0x880578 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 3

Enjoy, Have FUN! H.Merijn

In reply to Re: Devel::Peek output to a string? by Tux
in thread Devel::Peek output to a string? by perl5ever

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.