Re: proposed addition to perlvar

[email protected] (Matt Sergeant)
Newsgroups perl.perl5.porters
Message-ID <alpine.DEB.2.01.1006091450130.25687@bodger>
On Tue, 8 Jun 2010, Chas. Owens wrote:

> How about:
>
> =item $#
>
> C<$#> used to be a variable that could be used to format printed number.
> After a deprecation cycle, its magic was removed in 5.10 and using it
> now triggers a severe warning: C<$# is no longer supported>.
>
> C<$#> is also used as sigil, which, when prepended on the name of an
> array gives the index of the last element in that array.
>
>    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?

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