rvosa has asked for the wisdom of the Perl Monks concerning the following question:
And I do the following:package Node; sub new { my $class = shift; my $self = {}; my $self->{parent} = undef; bless $self, $class; return $self; } sub parent { my $self = shift; if ( @_ ) { $self->{parent} = shift; } return $self; }
Does the hash value $child->{parent} now hold the blessed hash that was created when I did $parent = new Node;, or a reference to it? I think it's a reference, but I'm not completely sure...use Node; my ( $child, $parent ) = ( new Node, new Node ); $child->parent($parent);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: objects are references, right?
by polettix (Vicar) on Jul 05, 2005 at 23:46 UTC | |
by rvosa (Curate) on Jul 06, 2005 at 00:36 UTC | |
by QM (Parson) on Jul 06, 2005 at 17:38 UTC | |
|
Re: objects are references, right?
by dragonchild (Archbishop) on Jul 06, 2005 at 01:06 UTC | |
|
Re: objects are references, right?
by Joost (Canon) on Jul 06, 2005 at 10:10 UTC |