hi,all,
I'm try my best to write a programme in using package structure. But I don't have any
experience at the side, I packed all common subroutines in a package including all
relative variables for these subroutines and my main programme, It seem wrong,
however, all these variables couldn't be use and infected those subroutine. How can I
start a programme in package? How do I orgnize the variables for package-self and main
programme? I want to bind some public variables into package, can I do so?
Any suggestion are appreciated!
Followed is my example:
Package:
package pt;
use 5.0000;
$a="ok"; #for public using
$b="It's";
# I don't know why put the newsubroutine in this package,
# perhaps, it is a constructer, I copy from PERL's manual,
# but it seem don't do anything.
sub new {
my $type = shift;
my $self = {};
bless $self,$type;
}
sub displaysub() {
return $b;
}
package main; # My application
use pt
$c=pt->new();
print $c->displaysub().$a;
This programme may output "It's", but no "ok", for I using $a out from package. So how
can I transfer value from outside of package to package's variable?
PS. Where can I get completed example about package using.
�й�Ѱ����
ǧ������Ѱ���㡭����
------------------------------------------------
�л������ʾ�