以下の例では、オブジェクト間の「包含」および「使用」といわれる関係をイン プリメントする方法を示します。
package Bar;
sub new {
my $self = {};
$self->{'buz'} = 42;
bless $self;
}
package Foo;
sub new {
my $self = {};
$self->{'Bar'} = new Bar ();
$self->{'biz'} = 11;
bless $self;
}
package main;
$a = new Foo;
print "buz = ", $a->{'Bar'}->{'buz'}, "\n";
print "biz = ", $a->{'biz'}, "\n";
Go to the first, previous, next, last section, table of contents.