|Perl Monk, Perl Meditation|
Re: How to sub class-esby kcott (Bishop)
|on May 15, 2020 at 07:21 UTC||Need Help??|
"... I have Robo class, which subclass from Robo::Arm Robo::Head Robo::Feet ..."
I may be misinterpreting your intent; however, I think you may want an OO structure something like this.
"... I learned I can use Exporter ... to obtain methods from other class(modules)."
"method names (because you don't need to and that's likely to not do what you want),"
If you are hand-crafting all of your classes — which, unless it's for a learning exercise, I don't recommend — the parent pragma would probably be the way to go (note that the base pragma is generally discouraged).
Take a look at "perlootut: PERL OO SYSTEMS". You haven't supplied enough information for a recommendation; perhaps try Moose and Moo first.
"However, if a method is not solely depends on themselves, I mean, the being called method require attributes defined in the class's own constructor to work properly, the tricks of above will not work. The result is that I can access the method, but the method won't work properly."
I don't understand what you're trying to describe in that paragraph. Showing some code pointing out what you want versus what you're getting would help greatly. Take a look at SSCCE.
"Is that any trick that you can kick on the constructor ..."
After following the advice above, you may find this is unnecessary. If you still need it, how it is achieved will depend on the code you use. I'm very much guessing here but, if you chose Moose, then something documented in "Moose::Manual::Construction: OBJECT CONSTRUCTION HOOKS" would likely be what you're after.