Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: recursive creation of attached objects?

by roboticus (Chancellor)
on Sep 14, 2012 at 13:57 UTC ( #993728=note: print w/ replies, xml ) Need Help??

in reply to recursive creation of attached objects?

You might play with this a bit:

#!/usr/bin/perl use 5.14.0; use warnings; use autodie; use Data::Dumper; my $t = myTree::create_tree(5); print Dumper($t); package myTree; sub create_tree { my $depth = shift; my $object = { left =>$depth ? create_tree($depth-1) : undef, right=>$depth ? create_tree($depth-1) : undef }; return bless $object; }


When your only tool is a hammer, all problems look like your thumb.

Comment on Re: recursive creation of attached objects?
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-10-06 20:44 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (160 votes), past polls