Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl's changes in the use of packages
by Marshall (Canon) on Jul 07, 2017 at 00:05 UTC | |
|
Re: Perl's changes in the use of packages
by Anonymous Monk on Jul 06, 2017 at 19:45 UTC | |
by Jambo Hamon (Novice) on Jul 07, 2017 at 11:08 UTC | |
|
Re: Perl's changes in the use of packages
by Anonymous Monk on Jul 07, 2017 at 02:17 UTC | |
|
Re: Perl's changes in the use of packages
by 1nickt (Canon) on Jul 06, 2017 at 18:48 UTC | |
by choroba (Cardinal) on Jul 06, 2017 at 20:06 UTC | |
by 1nickt (Canon) on Jul 06, 2017 at 23:30 UTC | |
by Anonymous Monk on Jul 07, 2017 at 19:24 UTC | |
|
Re: Perl's changes in the use of packages
by Anonymous Monk on Jul 07, 2017 at 19:51 UTC |