proposed addition to perlvar

[email protected] ("Chas. Owens")
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
Due to some [confusion a new user had][1] finding the documentation
for what $# does in $#foo, I suggest we add a small note to perlvar to
point people in the right direction (patch inlined).

diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index ed90610..359dd62 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -879,6 +879,17 @@ as described below.

 Also see L<Error Indicators>.

+=item $#
+
+C<$#> is not a variable; it is a sigil like C<@> that can be prepended
+on the name of an array to get the index of the last item 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"
+
+Also see L<perldata>.
+
 =item $PROCESS_ID

 =item $PID


[1] : http://stackoverflow.com/questions/2997042/where-is-the-documentation-for

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
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.