Re: proposed addition to perlvar

[email protected] (Steffen Mueller)
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
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.

--Steffen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.