sub new { #Arg0 is the type because the constructor will look like # my($instance) = Tree->new(arg1,arg2,whatever) #so arg0 will be Tree. my($type) = $_[0]; #Make subroutine-local var $self, and make it a reference. #Specifically, make it a reference to a (right now) empty hash. #Later on, that hash will contain object properties. my($self) = {}; #For now, we'll have one instance variable (property, whatever) #It will be in the hash referenced by $self, and will have #the index 'root'. This will be the first arg (inside the parentheses) #of the call to the constructor in the main program. $self->{'root'} = $_[1]; #remember $_[0] was the Tree before the -> #There's nothing reserved about the word $self. It could have been #called $oodolaboodola. To link the object with both the hash pointed #to by $self and the type (Tree), we use the 2 argument version #of the keyword bless: bless($self, $type); #Now finally, return the hash as a reference to be used as an "object" return($self); }