ここではStudentクラスの中でHumanクラスを利用しています。
new()の中でHumanのオブジェクト$manを作成し、
get()やshow()の中で利用しています。
また、show2()の中では、Humanのオブジェクト作成と利用を行っています。
ファイル名:Student.pm
package Student;use strict; use Human; my $man; ########### $man = Human->new();
|
実行ファイル名:test1.pl
use strict; use Data::Dumper; use Student;my $stu = Student->new(); $stu->get( 1 ,2 ); $stu->show( ); $stu->show2(10,20 ); |
実行結果:
>perl test1.plStudent show = 3 Student show2 = 30 |