June 2001 Making a Module Back Slide 41 Forward

Constructor

sub new
{
	my (%parameters) = @_;
	my %self;

	#some other initialization code and filling %self

	return bless (\%self);
}

use Some::Module;
$object = new Some::Module (%parameters);

  • A constructor is used to make an object
  • The constructor does not need to be named 'new'
  • The blessed thingy is the object that is passed around


Copyright © 2001 R. Geoffrey Avery Back Contents Forward