Re: proposed addition to perlvar
[email protected] (demerphq)
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
On 9 June 2010 17:16, Steffen Mueller <[email protected]> wrote: > Matt Sergeant wrote: >> >> On Tue, 8 Jun 2010, Chas. Owens wrote: > > [...] >>> >>> my @a = ("a", "b", "c"); >>> my $last_index = $#a; # $last_index is 2 >>> my $last_element = $a[$#a]; # $last_element is "c" >> >> Do we want to "encourage" this kind of use or prefer to encourage the [-1] >> format? > > Good point. This: "foreach (0..$#ary)" seems like a good idea to prevent > Obiwan errors. "$ary[$#ary]" seems a fairly unnecessary use of \W to me. I find it moderately ironic that in the worst case $#ary /will/ return -1. And that when it does so, this code will throw an error. cheers, Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"