Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Objects and passing/calling methodsby driador (Novice) |
on Sep 22, 2018 at 20:01 UTC ( [id://1222851]=perlquestion: print w/replies, xml ) | Need Help?? |
driador has asked for the wisdom of the Perl Monks concerning the following question:
Greetings all. This humble novice requests your assistance... Imagine I have a base package (SomePackage.pm) that performs a number of functions against a website with a restful interface. That package is written in a perl OO way, with a new() constructor. Another script (caller.pl) will be the user of this package. That said, I have a number of other sub modules in the base package: SomePackage::Auth.pm, SomePackage::Client.pm, SomePackage::Tickets.pm, etc. Auth provides the methods to handle authentication to a given site. Client provides a LWP::UserAgent and any methods around certain functions the website offers. Tickets provides methods to create/modify/manage tickets on the site. The goal I have here is that in the caller.pl, I instantiate the base package SomePackage->new; That sets up the base as well as setting up internal members to be a client (via SomePackage::Client) and ticket (via SomePackage::Ticket). It also has a method wrapper around SomePackage::Ticket's createTicket method:
Now, in caller.pl, I do something like
On running caller.pl, I get use of unitialized value in subroutine entry. What is the proper way to structure classes/objects such that makes passing internal attributes/objects around painless? Am I going about this wrong way? TIAA perl OO newb
Back to
Seekers of Perl Wisdom
|
|