develooper Front page | perl.beginners | Postings from January 2002

Packages in CGI

Thread Next
K Old
January 3, 2002 18:56
Packages in CGI
Message ID:
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 in it is in my @INC, and then put use 
MyPackageName; at the top of any given .pl file that wants to use it.

Now, from there, do I:

1) call the subroutine by 

2) call the subroutine by 
                                    $billing = new MyPackageName;
                                    $bill_results = $billing->do_billing();

Or, am I way off track?

Any help is appreciated.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About