Use a .pm file as a .pl file?

E

Electrorog

Hello. My University doesn't have the Perl modules installed that I
want to use but said that I can install them in my own directory for my
own use. I can access my directory but when I put the .pm file (like
NetPacket::TCP) and try to run my .pl file, I still get the can't find
module error since Perl is still looking in the same place for the
modules using @INC I assume (I am not a CS major so this is proving to
be frustrating). I was wondering if I could just save the .pm file as
a .pl file, put my code that I want to run at the end of the .pm file
and run it that way. If I can't, could someone please tell me how I
can use these great modules in a private directory? I appreciate any
help.

Roger
 
A

A. Sinan Unur

Hello. My University doesn't have the Perl modules installed that I
want to use but said that I can install them in my own directory for
my own use.

You should check the FAQ before you post.

perldoc -q lib

or

http://perldoc.perl.org/perlfaq8.html#How-do-I-keep-my-own-module/library-directory?

Sinan

--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
T

Tad McClellan

could someone please tell me how I
can use these great modules in a private directory?


Your Question is Asked Frequently:

perldoc -q module

How do I keep my own module/library directory?
 
B

Ben Morrow

Quoth (e-mail address removed):
Hello. My University doesn't have the Perl modules installed that I
want to use but said that I can install them in my own directory for my
own use. I can access my directory but when I put the .pm file (like
NetPacket::TCP)

It is generally better to install Perl modules properly, using the
Makefile.PL/Build.PL than just copy them into the relevant directories.
This way XS modules get built, and any other configuration necessary is
done as well. MakeMaker (Makefile.PL) has a PREFIX option; read perldoc
ExtUtils::MakeMaker. Module::Build (Build.PL) has an install_base
option; read perldoc Module::Build.
and try to run my .pl file, I still get the can't find
module error since Perl is still looking in the same place for the
modules using @INC I assume (I am not a CS major so this is proving to
be frustrating). I was wondering if I could just save the .pm file as
a .pl file, put my code that I want to run at the end of the .pm file
and run it that way.
No.

If I can't, could someone please tell me how I
can use these great modules in a private directory?

perldoc lib

Ben
 
B

Babacio

Tad McClellan
Your Question is Asked Frequently:

perldoc -q module

How do I keep my own module/library directory?

This one can be useful too:

perldoc -q 'search path'

How do I add the directory my program lives in to the module/library
search path?

use FindBin;
use lib "$FindBin::Bin";
use your_own_modules;
 
T

Tad McClellan

Babacio said:
Tad McClellan


This one can be useful too:

How do I add the directory my program lives in to the module/library
search path?


And the OP would have seen that one too with the query that I provided.
 
M

Michele Dondi

perldoc -q 'search path'

How do I add the directory my program lives in to the module/library
search path?

use FindBin;
use lib "$FindBin::Bin";
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^

Incidentally while we're there we should note that this FAQ entry is
giving a bad example, given that we warn people all the time against
always quoting variables...


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top