http://qs321.pair.com?node_id=935749

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',

Replies are listed 'Best First'.
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