-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array-dereferencing fails silently in Autoloaded functions while direct reference access works #22842
Comments
I can't reproduce this using only the code you have shown. Are you using a module like Time::localtime? Can you show a complete example of a broken module, rather than just a fragment? |
That's not the same values. The core my @parts = localtime();
foreach my $val (localtime()) { } If you're using a module that overrides my @parts = @{ localtime() };
foreach my $val (@{ localtime() }) { } (However, if you're using Not sure what any of this has to do with autoloading. |
The only thing likely to be relevant to AutoLoader is that it means all of your code runs with strict off, so it will hide some problems. |
Thank you very much for your valued feedback. The problem has been with me for several weeks. As a brief general explanation, the code ran unchanged for many years, was used excessively (as timestamp queries) and never caused any problems. My main Perl module had the following structure, whereby the connection to the database should be irrelevant.
The autoloaded function had the following content:
After instantiation of the Module with the object variable "$C" I called an autoloaded function "$C->now(1)" via autoload-Funktion (File ".../auto/ScreenPoint/Core/now.al"): Instead of the expected timestamp, I often got a zero value back through “localtime(time)”:
What currently always works as an emergency solution is to move the identical code to my main module ScreenPoint::Core.pm. The code runs in Apache / Perl / Mason environment. Thank you all for your tips. |
Module: AutoLoader
Description
I discovered a reproducible issue where array dereferencing behaves unexpectedly within autoloaded functions, while working perfectly fine in regular module functions.
Specifically, when using localtime() in an autoloaded function, accessing the array elements via direct assignment fails silently - the variables remain undefined. However, accessing the same values through a foreach loop with the array reference works correctly.
Steps to Reproduce
In autoloaded function (e.g., auto/MyModule/test.al):
Expected behavior
Workaround:
Perl configuration
The text was updated successfully, but these errors were encountered: