Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993728]
[marto]: FWIW, people shipping things as perl, which aren't strictly perl can cause confusion (Perl and OpenWrt - where to the communities intersect?)
[marto]: cpanm is lighter on resources than cpan, which is handy when working with consumer grade NAS hardware

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2018-03-17 13:23 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (224 votes). Check out past polls.