Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > manage importing modules

Reply
Thread Tools

manage importing modules

 
 
superprad@gmail.com
Guest
Posts: n/a
 
      03-23-2006
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).

 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      03-23-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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;
}
}

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      03-23-2006
<(E-Mail Removed)> wrote in comp.lang.perl.misc:
> 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
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
 
Reply With Quote
 
pkilambi@gmail.com
Guest
Posts: n/a
 
      03-24-2006
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing v reloading modules modules Peter Peyman Puk Python 0 03-19-2010 05:09 PM
How to keep a module with the same name as a module it is importing from importing itself? plb Python 2 02-08-2005 03:14 PM
Importing modules from within other modules Tobiah Python 2 09-14-2003 09:18 PM
Importing/reloading modules OKB (not okblacke) Python 0 09-04-2003 05:25 AM



Advertisments