develooper Front page | perl.perl5.porters | Postings from September 2010 and displaying array/hash elements

Dave Mitchell
September 18, 2010 06:56
Subject: and displaying array/hash elements
Message ID:
The current behaviour of's Dump function (and by extension the
underlying Perl_do_sv_dump() function in dump.c) is most unsatisfactory
when it comes to displaying arrays and hashes, and the elements thereof.
It conflates the 'nest' arg (how many levels deep of recursion to go) with
a 'how many elements to display' arg. This means that with a nest of 1,
one element is dumped; with a nest of two, two elements are displayed,
each element being dumped with a recursion depth of one; with nest == 6,
six elements are dumped, each being recursively dumped in great detail;

I propose changing the behaviour to the following:

when dumping an array/hash,

if nest == maxnest
    don't display any elements

if nest == maxnest-1
    display *all* elements, but just a compact one line per element:

	Elt "some_key" HASH = 0x5e637a77 VALUE = 0xa6ddd0
	Elt "otherkey" HASH = 0xe4b53fbc VALUE = 0xa39ed8

if nest < maxnest-1
    display all elements, and dump each value at depth (nest+1):

	Elt "some_key" HASH = 0x5e637a77
	    SV = PVGV(0xa4ecd8) at 0xa6ddd0
	      REFCNT = 1
	      FLAGS = (...)
	Elt "otherkey" HASH = 0xe4b53fbc VALUE = 0xa39ed8

This would be a change to the documented behaviour of

Nothing ventured, nothing lost. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About