Alright lost in translation. Below a recreated version of the problem. Please pardon that class 1 & 2 look identical here, in code how they use the return value of myCommonLib::bar is where they differ. I'm providing 2 versions of myCommonLib.pm because I've tried it multiple ways, both produce the same error, that function class2::bar() doesn't exist.
# This is tmp.pl use strict; use warnings; push(@INC, 'c:\perl\programs'); # this is where all code lives use class1; # Note, switching order here flips the error to class 1 use class2; my $C1 = new class1; my $C2 = new class2; $C1 -> FOO; $C2 -> FOO; # This line hits the error "undefined Class2::bar" # End tmp.pl file # start class1.pm file package class1; use strict; use warnings; use myCommonLib; #Contains function bar() sub new { ... } # builds an object, blesses it etc sub FOO { bar(); } 1; # End class1.pm # start class2.pm file package class2; use strict; use warnings; use myCommonLib; #Contains function bar() sub new { ... } # builds an object, blesses it etc sub FOO { bar(); # This line errors. myCommonLib::bar(); # Produces the similiar error that # "myCommonLib::bar()" doesn't exist } 1; # End class2.pm # File myCommonLib.pm Version 1 use strict; use warnings; sub bar { print "hello world"; } # End file myCommonLib.pm Version 1 # File myCommonLib.pm Version 2 package myCommonLib; use strict; use warnings; sub bar { print "hello world"; } 1; # End file myCommonLib.pm Version 2

In reply to Re^2: use a package multiple times by Anonymous Monk
in thread use a package multiple times by Anonymous Monk

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.