I have a class named Widget in a file named Widget.pm.  I have another class 
named Table in a file called Table.pm.  Table extends Widget.

---

package Widget;
#file Widget.pm

#insert a bunch of methods...  

---

package Table;
#file Table.pm
use Widget;
@ISA=("Widget");

#insert several methods here...

1;

---

package Framework;
#file Framework.pm
use Widget;
use Table;
1;

---

What I was doing was adding "use Widget;" and "use Table;" to the top of the 
program that uses these classes.  But, because I expect this library of classes 
to grow significantly I created a third .pm file called Framework.  Inside the 
Framework.pm I added the "use Widget;" and "use Table;" and now I only "use 
Framework;" in my application.

#!/usr/bin/perl
#test.pl
use strict;
use warnings;
use Framework;

#This line of code seems replaceable by either 
#of the next 2 commented lines
my $some_var_of_class_widget = new Widget();

#uncommented, the next line of code seems to work too...
#my $some_var_of_class_widget = Widget->new();

#uncommented, so does the next line of code
#my $some_var_of_class_widget = Widget->new;

my $table = new Table();

#insert several tests here...

This was a guess that happened to work.  My queston is if this is a common 
solution to reducing the number of "use" lines?  Is there a better solution 
that wouldn't cause the all classes to get compiled at runtime every time I 
"use Framework;" especially since all applications that use the Framework may 
not need the entire suite of classes contained in the framework?

--
Ronald Weidner

Reply via email to