Skip Menu |

This queue is for tickets about the Data-Skeleton CPAN distribution.

Report information
The Basics
Id: 78222
Status: resolved
Priority: 0/
Queue: Data-Skeleton

People
Owner: Nobody in particular
Requestors: garu [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: doesn't handle circular references
Hi there! First of all, great module! I was browsing for ideas to integrate to Data::Printer and printing only the skeleton of a data structure looks like a nice feature. Of course, Data::Printer outputs text, so if one wants the actual data structure, I want to point them at your module :) One thing struck me, though: Data::Skeleton doesn't seem to be able to handle circular references: % perl -MData::Skeleton -e 'my $page = {}; $page->{circular} = $page; my $s = Data::Skeleton->new; my $skel = $s->deflesh($page);' Deep recursion on subroutine "Data::Skeleton::_blank_hash" at /Users/garu/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/Data/Skeleton.pm line 107. The fix looks pretty straightforward: just keep track of each nested reference (including the top level one) and don't enter it if you've seen it already. The reason I haven't written it yet is because I'm not sure if this is per design, or if you have other plans on how to handle circular references. Cheers!
Thanks Garu! I've patched Data::Skeleton based on your advice. - Mateu On Thu Jul 05 12:45:22 2012, GARU wrote: Show quoted text
> Hi there! First of all, great module! > > I was browsing for ideas to integrate to Data::Printer and printing > only > the skeleton of a data structure looks like a nice feature. Of course, > Data::Printer outputs text, so if one wants the actual data structure, > I > want to point them at your module :) > > One thing struck me, though: Data::Skeleton doesn't seem to be able to > handle circular references: > > % perl -MData::Skeleton -e 'my $page = {}; $page->{circular} = $page; > my > $s = Data::Skeleton->new; my $skel = $s->deflesh($page);' > > Deep recursion on subroutine "Data::Skeleton::_blank_hash" at > /Users/garu/perl5/perlbrew/perls/perl- > 5.16.0/lib/site_perl/5.16.0/Data/Skeleton.pm > line 107. > > The fix looks pretty straightforward: just keep track of each nested > reference (including the top level one) and don't enter it if you've > seen it already. The reason I haven't written it yet is because I'm > not > sure if this is per design, or if you have other plans on how to > handle > circular references. > > Cheers!