in reply to treemap

Monkeying around further I found that adding this to the end of the example:
$data->{numref} = \$data->{nums}->[0];
Produces this after the first pass:
$VAR1 = { 'nums' => [ '-=ONE=-', ...], 'numref' => \'-=-=ONE=-=-', ...
The link is lost and the leaf is visited twice.

Repeating the "-=\U$_=-" line, gives

'nums' => ['-=-=ONE=-=-', ... 'numref' => \'-=-=-=ONE=-=-=-', ...
Not likely to be a problem, but worth the note.
Update:possible fix:
$refs->{ref($_) ? $_: \$_} = undef;