Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Replacement for substr(Data::Dumper($x), 0, 4000)

by educated_foo (Vicar)
on Jan 17, 2012 at 15:13 UTC ( [id://948333]=note: print w/replies, xml ) Need Help??


in reply to Replacement for substr(Data::Dumper($x), 0, 4000)

Does $Data::Dumper::Maxdepth fix things for you? If not (i.e. if you want to truncate a depth-first printout), then you may have to roll your own. You also *might* be able to wrap Data::Dumper::_dump() to keep track of how much it has produced, then use goto LABEL or die() to jump out when you have enough output. But Data::Dumper is partially XS, so that could be dangerous.

Replies are listed 'Best First'.
Re^2: Replacement for substr(Data::Dumper($x), 0, 4000)
by Tux (Canon) on Jan 17, 2012 at 15:34 UTC

    stealing _dump was my first hunch too, but is that is called on (sub)values, it will be very hard to catch the *total* size. And you will have to force using Dumpperl (a.o.t. using the much faster Dumpxs).

    { my $size = 0; my $org_dump = \&Data::Dumper::_dump; sub Data::Dumper::_dump { $size >= 4000 and return ""; my $s = $org_dump->(@_); $size += length $s; return $s; } }

    could be a crude start ...


    Enjoy, Have FUN! H.Merijn
Re^2: Replacement for substr(Data::Dumper($x), 0, 4000)
by mje (Curate) on Jan 17, 2012 at 15:38 UTC

    Maxdepth does not really help as I want the initial 4K to be correct (with no omissions) as far as it goes. _dump sounds interesting and I will look at it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://948333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-19 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found