Perl programming on MPE/iX - April 2002

Solution Symposium Page 27April 4, 2002
object definitions example - Foo.pm
package Foo;
sub new { # method subroutine
my ($class_name) = @_;
my ($self) = {}; # create an empty hash to store attributes
bless ($self, $class_name); # make it an object
$self->{'_created'} = 1;
return $self;
}
sub put { # method subroutine
my ($self, $data) = @_;
$self->{_bar} = $data; # store data in the _bar attribute
}
sub get { # method subroutine
my ($self) = @_;
return $self->{_bar}; # return data from the _bar attribute
}
1; # return code for use statement