in reply to New error message in ActivePerl 5.22

G'day dhannotte,

"1) Why isn't Carp identifying the correct line?"

Perl will do its best to parse whatever code you provide. When it decides it definitely can't continue, it provides the line number where it gave up. It could be the problem line; it could be within the next few lines; it could be many pages of code later. Whilst it obviously depends on the code in question, the second case is probably the most common; the first case is less common; and, for the third case, you'll often get some sort of hint (e.g. Might be a runaway multi-line %s string starting on line %d).

So, for your posted problem, look at the lines just before 2842 for code like "defined @some_array_name".

"2) Besides going through 101 occurences, how can I find where (and WHAT) this error really is? "

You can look in perldiag for diagnostic messages. Here you'll find the error message you posted along with a description of the problem.

You've shown "testplx.pl in its entirety". That code is missing these two lines (which should be at the top):

use strict; use warnings;

[See strict and warnings for details.]

As a developer tool (i.e. don't include this in production code), you can also use the diagnostics pragma: this will give you the full description associated with the diagnostic message.

I suspect your other code is also missing one, or both, of those lines. Plx.pm certainly doesn't have warnings: if it did, you would have received deprecation warnings (not errors) and could have fixed them as they occurred. Presumably, after receiving the first few, you would have stopped making that mistake.

Rather than looking at every instance of defined in your code, many of which may be perfectly fine (e.g. defined $some_scalar), it might be easier to keep running your script and fixing each as they occur. Bear in mind that these are fatal errors; each will be reported separately, even if they occur on the same line:

$ perl -E 'my (@x, @y); say defined(@x) ? 1 : 0; say defined(@y) ? 1 : + 0' Can't use 'defined(@array)' (Maybe you should just omit the defined()? +) at -e line 1. $ perl -E 'my (@x, @y); say @x ? 1 : 0; say defined(@y) ? 1 : 0' Can't use 'defined(@array)' (Maybe you should just omit the defined()? +) at -e line 1. $ perl -E 'my (@x, @y); say @x ? 1 : 0; say @y ? 1 : 0' 0 0

— Ken

Replies are listed 'Best First'.
Re^2: New error message in ActivePerl 5.22
by dhannotte (Acolyte) on Dec 25, 2017 at 16:52 UTC
    Thanks everyone for your excellent advice. Unfortunately, I've spent almost all of this year in hospitals and rehab centers and no longer have the time to hunt down each and every anomaly that has made my labor of love an inoperable monstrosity. I'm putting my affairs in order and need to fix some critical bugs in this product before it's too late. Please, can someone provide me with a version of 5.10 so I can release my software before my chance to contribute something to this sad world is over. Thanks.
      Can't help with ActivePerl (but their page mentions 5.10 as supported in their enterprise edition). I'd go for StrawberryPerl; on their releases page they have 5.10.1.5 (May 2011). The ZIP edition (as opposed to the MSI installer) doesn't need admin privileges and therefore will not mess with the system's internals, which is why i prefer this method.

      Then there is berrybrew, which allows you to use multiple (Strawberry) Perl versions concurrently, so you could first get your scripts to work again using 5.10 and later switch to a newer Perl (and back and forth).

        Thanks for your great advice, soonix. I'm now working on installing, understanding and exploiting Strawberry. Since I don't get around much anymore I thought I'd just install the .MSI version of 5.10 but the installer issued the message "Installer is no longer responding" for an hour, so I had to give up. (I'll report this to them as soon as I have time to figure out their complicated reporting procedures.) So far I'm getting the same results whether I issue programname.pl or c:\perl programname.pl. In either case $] is set to 5.22, the version I'm trying to avoid. Is there any way my program can sense that it is running Strawberry Perl rather than ActiveState Perl?
        Do you actually use berrybrew?