manage importing modules

Discussion in 'Perl Misc' started by superprad@gmail.com, Mar 23, 2006.

  1. Guest

    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).
     
    , Mar 23, 2006
    #1
    1. Advertisements

  2. 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
     
    Gunnar Hjalmarsson, Mar 23, 2006
    #2
    1. Advertisements

  3. Anno Siegel Guest

    <> 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.
     
    Anno Siegel, Mar 23, 2006
    #3
  4. Guest

    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?
     
    , Mar 24, 2006
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. OKB (not okblacke)

    Importing/reloading modules

    OKB (not okblacke), Sep 4, 2003, in forum: Python
    Replies:
    0
    Views:
    321
    OKB (not okblacke)
    Sep 4, 2003
  2. Tobiah
    Replies:
    2
    Views:
    346
    Tobiah
    Sep 14, 2003
  3. Dave
    Replies:
    2
    Views:
    508
  4. plb
    Replies:
    2
    Views:
    401
  5. Peter Peyman Puk

    Importing v reloading modules modules

    Peter Peyman Puk, Mar 19, 2010, in forum: Python
    Replies:
    0
    Views:
    331
    Peter Peyman Puk
    Mar 19, 2010
Loading...

Share This Page