Hi, I've got 3 modules using eachother and that makes perl -c go crazy. This is what they look like:
a.pm:
package a; BEGIN { use Data::Dumper; print STDERR 'a:',Dumper \%INC; } use b; my $a = { foo => &b::bar () }; 1;
b.pm:
package b; BEGIN { use Data::Dumper; print STDERR 'b:',Dumper \%INC; } use c; sub bar { 1; } 1;
c.pm:
package c; BEGIN { use Data::Dumper; print STDERR 'c:',Dumper \%INC; } use a; 1;
running perl -c a.pm, except printing the %INC var in different states gives me:
Undefined subroutine &b::bar called at a.pm line 7. Compilation failed in require at c.pm line 6. BEGIN failed--compilation aborted at c.pm line 6. Compilation failed in require at b.pm line 6. BEGIN failed--compilation aborted at b.pm line 6. Compilation failed in require at a.pm line 6. BEGIN failed--compilation aborted at a.pm line 6.
Does anyone know why this happends? %INC holds all three modules. b.pm and c.pm both compile when doing perl -c on them. Also, removing "use c;" in b.pm makes a.pm compile.

In reply to Circular module dependencies by jmo

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.