Maybe I'm misunderstanding what you're asking, but as long as you include the use lib in program that uses the modules in question, you don't need to include it in any of these modules/classes. (Example below.)

In the following example, Foo.pm lives in /tmp/foobar, Bar.pm and my_script.pl live in the current directory, and Bar inherits from Foo. Not that neither Foo.pm nor Bar.pm make reference to any directory.

# /tmp/foobar/Foo.pm package Foo; !! 'keep require happy'; sub baz { print 'Hello from ' . shift() . '::baz' . "\n"; } __END__

# ./Bar.pm package Bar; use base 'Foo'; !! 'keep require happy'; __END__

# ./my_script.pl use lib '/tmp/foobar'; use Bar; Bar->baz(); __END__

% perl my_script.pl Hello from Bar::baz

In fact, I can even omit the use lib line from my_script.pl, by invoking it with

% perl -I/tmp/foobar my_script.pl
or
% perl -Mlib=/tmp/foobar my_script.pl

the lowliest monk


In reply to Re: How can you make 'use lib "foo"; dynamic? by tlm
in thread How can you make 'use lib "foo"; dynamic? by martell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.