M
Mahesh
I have two packages package1 and package2.
Suppose this the code of package1
package package1;
my $file_scope_var = "var in package1"
sub new
{
my $proto = shift;
my $self = { };
my $class = ref ($proto) || $proto;
bless ($self, $class);
$self->{NAME} = undef;
}
sub print_package1
{
my $self = shift;
my $name = $self->NAME();
my $file_scope_var = $self->file_scope_var();
print"\n\n Name is $name and file scope var is $file_scope_var";
}
suppose the code of package2 is
package package2
@ISA=("package1");
sub new
{
my $proto = shift;
my $self = { };
my $class = ref ($proto) || $proto;
}
sub print_package2
{
my $self = shift;
$self->print_package1();
}
now my problem is that since Iam inheriting package1 into package2.
and Iam calling print_package1 in package2.
Will that call to print_package2 will print file_scope_var value or
not. Since it is a file scope variable will it get printed when we call
print_package2 or not.
Please help me in this soon as I was stuck in the middle of the work.
Thanks and Regards,
Mahesh
Suppose this the code of package1
package package1;
my $file_scope_var = "var in package1"
sub new
{
my $proto = shift;
my $self = { };
my $class = ref ($proto) || $proto;
bless ($self, $class);
$self->{NAME} = undef;
}
sub print_package1
{
my $self = shift;
my $name = $self->NAME();
my $file_scope_var = $self->file_scope_var();
print"\n\n Name is $name and file scope var is $file_scope_var";
}
suppose the code of package2 is
package package2
@ISA=("package1");
sub new
{
my $proto = shift;
my $self = { };
my $class = ref ($proto) || $proto;
}
sub print_package2
{
my $self = shift;
$self->print_package1();
}
now my problem is that since Iam inheriting package1 into package2.
and Iam calling print_package1 in package2.
Will that call to print_package2 will print file_scope_var value or
not. Since it is a file scope variable will it get printed when we call
print_package2 or not.
Please help me in this soon as I was stuck in the middle of the work.
Thanks and Regards,
Mahesh