On Fri, 12 Oct 2001, Bennett Haselton wrote:

> Presumably affects all versions of perl -- but how come if you run:
>
> @array = ('a', 'b', 'c');
> print join(" ", @array[0,0]), "\n";
>
> you get an array with *two* elements, i.e. the script prints "a a"?
>
> @array[0,0] ought to return an array with *one* element, with that element
> being $array[0].  This would be consistent with the properties of arrays
> that are returned for @array[x,y] when y > x -- i.e., the number of
> elements is y - x + 1.
>
> I guess it's up to the language designers, but I think it was a bad
> decision.  It's one more special case that you have to check for, because
> it's inconsistent behavior.

Its not inconsistnet at all if you understand what the semantic are
rather than what you think they "ought" to be.

What do you get if you do:
print join(" ", @array[0,1,2,2,1,0]), "\n"; ?

You are not accessing an array element but rather an array slice.
The stuff between the [] becomes the list of elements that are to
be returned.

**** [EMAIL PROTECTED] <Carl Jolley>
**** All opinions are my own and not necessarily those of my employer ****

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to