Perl programming on mMPE/iX - August 2001
HP World Page 26August 21, 2001
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