I have a foreach loop that operates on the elements of an array. However, the size of the array is variable. Here is the code segment:
Occasionally $#name will evaluate to 2. That seems to be when I get the error:
Use of uninitialized value in range (or flip)
Is it illegal to have a range with the same start and end values? Is there a way around this so I don't have to duplicate the code when $#name=2? TIA.
Code:
if ($#name>1) {
.
.
.
foreach my $part ($name[2..$#name]) {
.
.
.
Use of uninitialized value in range (or flip)
Is it illegal to have a range with the same start and end values? Is there a way around this so I don't have to duplicate the code when $#name=2? TIA.