Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:
I have a big object oriented module based on a hash. There's one list inside this module. I would like to have this list also as an object. But I wanted to try it without a separate module. So I want to have two packages in one module.
It is working if I specify the name directly. But if I want to have the name of the subpackage dependent on the name of the main package, I get an error. My code looks like this.
use strict; use warnings; package My; my $pkg_sub; BEGIN { $pkg_sub = __PACKAGE__ . '::A'; } # some methods package $pkg_sub; # My::A # some methods 1;
What am I doing wrong?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Name of subpackage dependent on main package
by davido (Cardinal) on Dec 29, 2019 at 23:34 UTC | |
Re: Name of subpackage dependent on main package
by haj (Vicar) on Dec 29, 2019 at 23:40 UTC | |
Re: Name of subpackage dependent on main package
by Tanktalus (Canon) on Dec 29, 2019 at 23:37 UTC | |
Re: Name of subpackage dependent on main package
by tobyink (Canon) on Dec 30, 2019 at 07:49 UTC | |
Re: Name of subpackage dependent on main package
by Anonymous Monk on Dec 29, 2019 at 21:31 UTC |