Re: proposed addition to perlvar

[email protected] (David Golden)
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
On Wed, Jun 9, 2010 at 10:52 AM, Matt Sergeant <[email protected]> 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?

Maybe this instead:

  my @a = ("a", "b", "c");
  say "Element $_ is $a[$_]" for 0 .. $#a;

-- David
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.