Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thankyou Aristotle.

In it's veryCompact form the output is exactly what I was looking for:

P:\test>perl -MDumpvalue -e" $d=new Dumpvalue; $h{ $_ } = [ map{ $_ & 1 ? { 'a'..'z' } : [ 1..100 ] } 1 .. 10 ] for 'a' .. 'j'; $d->veryCompact(1); $d->dumpValue( \%h )" 'a' => ARRAY(0x1871700) 0 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 1 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 3 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 5 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 6 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 7 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 9 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 'b' => ARRAY(0x18757e4) 0 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 1 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 3 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 5 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 6 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 7 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 9 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 'c' => ARRAY(0x18794fc) 0 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 1 0..99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

And it even has an option to see through overloading and handle what comes out -- at least part way.

P:\test>p1 perl> use Math::Pari qw[ :int factorint sqrtint divisors PARI ];; perl> $f = factorint 1000000;; perl> use Dumpvalue;; perl> $d = new Dumpvalue;; perl> $d->veryCompact( 1 );; perl> $d->set( bareStringify => 1 );; perl> { local $\; $d->dumpValue( $f ) };; 0 Math::Pari=ARRAY(0x1a3702c) 0 Math::Pari=SCALAR(0x1a3c9ec) -> 33884400 1 Math::Pari=SCALAR(0x1a3ec7c) -> 33884376 1 Math::Pari=ARRAY(0x1a36f54) 0 Math::Pari=SCALAR(0x1a3ec70) -> 33884388 1 Math::Pari=SCALAR(0x1a3ec94) -> 33884364 perl> Terminating on signal SIGINT(2)

All it needs is to not de-overload the final SCALAR values so that Math::Pari will return the numbers, which as it's in Perl, I can fix.

It also does circularity testing:

perl> $r = \$r;; perl> $d->dumpValue( $r );; -> REF(0x22ac9c) -> REUSED_ADDRESS

But dumping my testcase above, it uses less than 50% extra memory--a considerable saving over the 250% of Data::Dumper. Though I now realise that a large proportion of the extra memory is DD consumes is used by building the output in memory rather than dumping straight the select'd output handle.

I think I can see how to reduce that further still--though it may slow it down a little.

And it's been sat there on my machine the whole time! It's a bit embarrassing that I've never noticed it, but I don't ever recall it being mentioned.

Not only did someone else see the need for what I was asking for, they wrote it, covered all the bases and dropped it on my machine without telling me:)

Once again, thanks Aristotle.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re^2: In need of a Dumper that has no pretentions to being anything else. by BrowserUk
in thread In need of a Dumper that has no pretentions to being anything else. by BrowserUk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2024-04-18 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found