$#array
just gives you the last index in the array that contains a value where @array
returns you the size of the array when used in a scalar context, which would return you 1 greater than that.
For example:
#!/usr/bin/perl
@array = ();
push(@array,10);
push(@array,11);
print $#array, "\n"; # Prints 1
print scalar(@array), "\n"; # Prints 2
print $array[$#array], "\n"; # Prints 11 (i.e. the last element)
Having stated that, you're split is creating a list of only one element. So $#array
is going to provide you 0. Accessing an array with the subscript -1 will also give you the last element in your array, which b/c you only have one in your array, the expression $#info - 1
equates to -1
(i.e. the last item in your array)
If you were to have 2 elements in your array, say: dog, cat. Then $#array
would yield cat while $#array - 1
would yield dog because you wouldn't be producing -1
with your expression $#info - 1
.