Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Efficient partial deep cloning

by toma (Vicar)
on Jan 11, 2008 at 05:13 UTC ( #661794=note: print w/ replies, xml ) Need Help??


in reply to Efficient partial deep cloning

Maybe you can use one of the B:: modules. I have only used them a couple of times, but it seems like they do the reflection that you are looking for. You end up in the internals because that's where the structure is.

For example:

use B::XPath; sub some_function { my $struct = [ 'whaa!', undef, [ undef, undef, { foo => 3 } ], { bar => 'baz' }, ]; } my $node = B::XPath->fetch_root( \&some_function ); print_children($node, 0); sub print_children { my $node= shift; my $indent= shift; foreach my $child ($node->get_children()) { print " " for (0..$indent); print $child->get_name()."=".$child."\n"; $indent++; print_children($child, $indent); $indent--; } }
It should work perfectly the first time! - toma


Comment on Re: Efficient partial deep cloning
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://661794]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2015-07-28 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls