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

Selectively truncating data structure dumps

by metaperl (Curate)
on Nov 03, 2011 at 18:52 UTC ( #935749=perlquestion: print w/ replies, xml ) Need Help??
metaperl has asked for the wisdom of the Perl Monks concerning the following question:

I have a nested hashref. At some point in this hashref, the key tz has a hashref as its value. One key in this hashref is spans. I want this hashref to not be printed or truncated to maybe 20 characters max. How can I use Data::Dump or something else to get a dump of the whole structure but with this one key greatly reduced in output amount? The docs to Data::Dump::Filtered are opaque to me. Here's a sample of my data structure:

$VAR6 = { 'stops' => [ { 'destination' => { 'dt' => bless( { 'local_rd_secs' => 54212, 'local_rd_days' => 734444, 'locale' => bless( { 'default_time_format_length' => 'mediu +m', 'native_language' => 'Engli +sh', 'native_territory' => 'Unite +d States', 'native_complete_name' => 'English United States', 'en_language' => 'Engli +sh', 'id' => 'en_US +', 'default_date_format_length' => 'mediu +m', 'en_complete_name' => 'English United +States', 'en_territory' => 'United States' }, 'DateTime::Locale::en_US' ), 'rd_nanosecs' => 0, 'utc_rd_secs' => 68612, 'local_c' => { 'hour' => 15, 'second' => 32, 'month' => 11, 'quarter' => 4, 'day_of_year' => 307, 'day_of_quarter' => 34, 'minute' => 3, 'day' => 3, 'day_of_week' => 4, 'year' => 2011 }, 'formatter' => undef, 'utc_year' => 2012, 'tz' => bless( { 'last_offset' => -18000, 'spans' => [ [ '-1.#INF', '59418032400', '-1.#INF', '59418014638',

Comment on Selectively truncating data structure dumps
Select or Download Code
Re: Selectively truncating data structure dumps
by Anonymous Monk on Nov 04, 2011 at 06:22 UTC
    I do something like
    { local $foo->{bar}{bar}{bar} = substr $foo->{bar}{bar}{bar}, 0, 20; Dump( $foo ); }
Re: Selectively truncating data structure dumps
by metaperl (Curate) on Nov 04, 2011 at 17:05 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://935749]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2014-12-18 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls