manage importing modules

S

superprad

Hi:
I am trying to use perl a bit more these days and have a question. I
have a module that I want to import say

use AA::BB;

but the problem is this call exists in a common place where it might or
might not have access to the module uts trying to upload and so it
errors off saying it cannot find this .

How else Could I write this so that i could avoid this error and also
keep this available to both instances. Heard of AuotLoad but never used
it. If that is the solution could some one give me an idea as to how to
go about loading my module with auto hide (may be the same example).
 
G

Gunnar Hjalmarsson

I am trying to use perl a bit more these days and have a question. I
have a module that I want to import say

use AA::BB;

but the problem is this call exists in a common place where it might or
might not have access to the module uts trying to upload and so it
errors off saying it cannot find this .

How else Could I write this so that i could avoid this error and also
keep this available to both instances.

BEGIN { eval "use AA::BB" }

or

BEGIN {
eval {
require AA::BB;
import AA::BB;
}
}
 
A

Anno Siegel

Hi:
I am trying to use perl a bit more these days and have a question. I
have a module that I want to import say

use AA::BB;

but the problem is this call exists in a common place where it might or
might not have access to the module uts trying to upload and so it
errors off saying it cannot find this .

How else Could I write this so that i could avoid this error and also
keep this available to both instances. Heard of AuotLoad but never used
it. If that is the solution could some one give me an idea as to how to
go about loading my module with auto hide (may be the same example).

See perldoc lib. Also look up the function of the environment variable
PERL5LIB in perlrun.

Anno
 
P

pkilambi

Thanks for your reply. I thought of eval,but the problem is I have a
script that I run as a monitor script to check use statements. This
will error off even if the keep the use statement in the eval. One way
is to modify my script such that it does not parse if it sees eval. Is
ther any other way?
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top