All,

Inherited a venerable project some time ago, full of amazing wonder and delight which dates back to the ancient time of perl 4.036. It's been well cared for over the years, and despite many perl version upgrades has performed successfully in every way, only needing minor tweaks and such to keep it 100% functional. A marvel.

These days, the code has now met its match in terms of syntax, and I guess the looser assumptions of how modules get require'd and how calls get made no longer hold true. An example in really short terms, given a script and its package, main.pl and package.pl.

main.pl: #/usr/bin/perl print "Entry point\n"; log('started'); sub log { # do the usual to open the logile # now print it print LOG @_; # close it }

And now the package:

package.pl: package mutex; sub update { # do something and log it &main'log("can't do something"); } 1;

I'm waaay oversimplifying many lines of code, but you get the idea.

So, in the old days, this would work: The package could call a routine in the calling routine and continue. It seems this worked fine until around perl 5.26 and now we get the "Undefined subroutine &main::log called at". Has the way this once worked before changed? Before anyone asks: There's a lot going on in the log() routine that would make it very hard to locate into its own package, and even then, I'm not sure package calling package will work.

Thanks,


In reply to Perl's changes in the use of packages 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.