Subject: | Problem with "while ($i <= @parts) {" |
Date: | Wed, 9 Oct 2019 15:38:10 +0100 |
To: | bug-Flexnet-lmutil [...] rt.cpan.org |
From: | Patrick McTiernan <patmct [...] patmct.plus.com> |
This line often leads to crashes in CentOS 6 and 7. This is line 343 of
lmutil.pm (Version 1.5).
This should be "while ($i <= $#parts) {"
because it is looping through the parts of the array variable @parts.
You need to stop one entry earlier, as this picks up one item *after*
the end of the line.
Some debugging using perl -de 0:
DB<1> @parts=(1,2,3);
DB<2> $n1=@parts;
DB<3> $n2=$#parts;
DB<4> print "n1=$n1, n2=$n2\n";
n1=3, n2=2
DB<5> print $parts[$n1];
DB<6> print $parts[$n2];
3
This clearly illustrates that you need $#parts rather than @parts, or
you could use
while ($i < @parts)
instead. That would work fine, too.