On 9/10/07, Pavanvithal Torvi <[EMAIL PROTECTED]> wrote: snip > If I make use of this feature will it cause compatibility issues with the > later versions of perl. snip
Negative indexing has been around at least since Perl 5 (and I think it goes back much farther than that). As for compatibility with future versions of Perl, you should have no problem with the Perl 5 line (e.g. 5.10, the next and possibly last Perl 5 release, although I believe they are planning Perl 5.12 now). That specific feature is changing in Perl 6 (which will be released eventually). In Perl 6 a negative index refers to elements before element 0*. That is this my @a = 1,2,3,4,5 @a[-1] = 6; will create a new element before the one holding 1 and put 6 there; so @a will now hold (6,1,2,3,4,5). If you wish to set the last element of a Perl 6 array you must use the whatever** symbol minus the number of elements you want to go back. So the Perl 5 code my @a = 1,2,3,4,5; $a[-1] = 6; would be my @a = 1,2,3,4,5; @a[*-1] = 6; The relevant Synopsis is S09: http://dev.perl.org/perl6/doc/design/syn/S09.html * Pugs appears to be broken in this regard, it still treats indexes like Perl 5 does and the whatever symbol maps to 0. ** from S02 «Ordinarily a term beginning with * indicates a global function or type name, but by itself, the * term captures the notion of "Whatever", which is applied lazily by whatever operator it is an argument to. Generally it can just be thought of as a "glob" that gives you everything it can in that argument position.» -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/