Taming the printing of @_

Do it in stages. Avoid 'x' as long as you need to if there's a possibility of an enormous data structure:

<DB> p "@_" ARRAY(0x38234) Big::Nested::Mess=HASH(0x382437) <DB> x keys %{ $_[1] } ...just the keys, so you can see what to look for...
When I was doing this a lot, I defined a p() subroutine that made a recursive copy of complex data structures, only the copy was something much more readable. This is assuming that the big nasty data structure is your own, and you have some application-specific notion of what would be more or less interesting to see in the output.
sub p { my $x = shift; if (! ref $x) { return $x; } elsif (ref($x) eq 'My::Class') { return bless { name => $x->{name}, manager => $x->{manager}->getId(), children => p($x->{children}), # add any other fields you want to see }, ref($x); } elsif (UNIVERSAL::isa($x, 'ARRAY')) { return [ map { p($_) } @$x ]; } elsif (UNIVERSAL::isa($x, 'HASH')) { return { map { $_ => p($x->{$_}) } keys %$x }; } else { return $x; } }
...tailored to your specific situation. (Actually, I think I also did a UNIVERSAL::can($x, 'p') to see if the object implemented its own readable-conversion method.)

Then you can do 'x p($whatever)' and get your customized dump. (You can take this farther, and pass in a "brevity level" parameter that starts out zero to display everything, but increases as you get into further nested things so that they will display as one-line summaries rather than structural dumps.)


In reply to Re: Debugger: I must be missing something by sfink
in thread Debugger: I must be missing something by throop

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.