> -----Original Message----- > From: K Old [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 03, 2002 9:56 PM > To: [EMAIL PROTECTED] > Subject: Packages in CGI > > > Hello all, > > I have a few questions about using packages in CGI. > > First, here is my situation. I am creating a account > management and billing > set of scripts and want to modularize it. I have most (if > not all of the > code) scattered among several .pl files and not necessarily > in subroutines, > but can easily be put into subroutines. > > Let's take one example. I have a need to use a subroutine called > do_billing() in more than one .pl file. > > Now, I would assume that all I need to do to make this a > package is at the > top of the file with do_billing() in it, I just put > > package MyPackageName; > > Then in any file that I want to use it, I just make sure that > the path to the > folder that has MyPackageName.pm in it is in my @INC, and > then put use > MyPackageName; at the top of any given .pl file that wants to use it.
Yes, but you're oversimplifying it somewhat. There are some other considerations. See perldoc perlmod > > Now, from there, do I: > > 1) call the subroutine by > MyPackageName::do_billing(); Yes, or even just do_billing(). See: perldoc Exporter > > 2) call the subroutine by > $billing = new MyPackageName; > $bill_results = > $billing->do_billing(); This can be done as well, but your package needs to be set up differently. See: perldoc perlboot -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]