Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Module Directory Structures 1

Status
Not open for further replies.

andyros

Programmer
Jul 12, 2005
42
GB
Hey all,

Right I've searched far and wide for this but can only find information on how to make a perl module, not how to organise them.

I've made a few perl modules, for example

Joe.pm
Andy.pm
Sam.pm

and i want to place them into a sub folder called PEOPLE.

So i assume i must rename the 'package' statement at the top of the modules to PEOPLE::Joe etc then move all the .pm's into that directory.

Now when i create a test script to call a print function from any one of these modules it says:

Code:
Can't locate object method "new" via package "Joe" (perhaps you forgot to load "Joe"?) at Test.pl line 4.

yet at the top of my Test.pl code i have included the statement:

use PEOPLE::Joe;

any ideas on how this is done? I'm going to have alot more files and i like things neat and tidy in folders :)!

thanks
andy
 
can you show us the new method that you create inside Joe.pm



``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Code:
sub new 
{
	my ($class) = @_;
	my $self = {};
	bless $self;
	return $self;
}
 
Everything works fine when the modules are in the same directory and i simply have

use Joe;
 
why don't you try to put the PEOPLE dir into a directory that is inside @INC ?


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
how is that done? i tried use lib(c:\perlfiles\PEOPLE\); but it didnt work :?
 
@INC contains paths for the perl modules.
if you do on the command line
Code:
perl -e 'print "$_\n" foreach(@INC)'
you will see some directories where the perl modules are.
Copy the PEOPLE dir inside one of those.

or at the begining of your script use
Code:
push(@INC,'the/path/to/the/folder/which/contains/the/dir/PEOPLE')
and then 'use myModule'


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
any time!


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top