Perldoc Search: "$#" perl-5.20.1

search official POD


14 PODs, 52 LINEs found.
perlfunc.pod
625 :             foreach $index (0 .. $#ARRAY) {
633 :             delete @ARRAY[0 .. $#ARRAY];
1516 :         Used as an lvalue, "keys" allows you to increase the number of hash buckets allocated for the given hash. This can gain you a measure of efficiency if you know the hash is going to get big. (This is similar to pre-extending an array by assigning a larger number to $#array.) If you say
2666 :                 $ARRAY[++$#ARRAY] = $value;
3014 :                 my @parameters = @$arrayref[1..$#$arrayref];
3441 :                                  } 0..$#old
3501 :         The following equivalences hold (assuming "$#a >= $i" )
perlvar.pod
527 :     @+      This array holds the offsets of the ends of the last successful submatches in the currently active dynamic scope. $+[0] is the offset into the string of the end of the entire match. This is the same value as what the "pos" function returns when called on the variable that was matched against. The *n*th element of this array holds the offset of the *n*th submatch, so $+[1] is the offset past where $1 ends, $+[2] the offset past where $2 ends, and so on. You can use $#+ to determine how many subgroups were in the last successful match. See the examples given for the "@-" variable.
551 :             Thus, after a match against $_, $& coincides with "substr $_, $-[0], $+[0] - $-[0]". Similarly, $*n* coincides with "substr $_, $-[n], $+[n] - $-[n]" if $-[n] is defined, and $+ coincides with "substr $_, $-[$#-], $+[$#-] - $-[$#-]". One can use $#- to find the last matched subgroup in the last successful match. Contrast with $#+, the number of subgroups in the regular expression. Compare with "@+".
574 :                         foreach my $idx (0..$#$ary) {
690 :     @ARGV   The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, *not* the program's command name itself. See "$0" for the command name.
1139 :     $#      $# was a variable that could be used to format printed numbers. After a deprecation cycle, its magic was removed in Perl v5.10.0 and using it now triggers a warning: "$# is no longer supported".
1141 :             This is not the sigil you use in front of an array name to get the last index, like $#array. That's still how you get the last index of an array in Perl. The two have nothing to do with each other.
perllol.pod
178 :         for $i ( 0 .. $#AoA ) {
184 :         for $i ( 0 .. $#AoA ) {
185 :             for $j ( 0 .. $#{$AoA[$i]} ) {
192 :         for $i ( 0 .. $#AoA ) {
194 :             for $j ( 0 .. $#{$aref} ) {
201 :         for $i ( 0 .. $#AoA ) {
perldsc.pod
240 :      for $i ( 0 .. $#AoA ) {
245 :      for $i ( 0 .. $#AoA ) {
246 :          for $j ( 0 .. $#{ $AoA[$i] } ) {
304 :          foreach $i ( 0 .. $#{ $HoA{$family} } ) {
396 :      for $i ( 0 .. $#AoH ) {
405 :      for $i ( 0 .. $#AoH ) {
perltie.pod
123 :     FETCHSIZE and STORESIZE are used to provide $#array and equivalent "scalar(@array)" access.
268 :               $self->STORE( $last + $_, $list[$_] ) foreach 0 .. $#list;
296 :               @{$self->{ARRAY}}[ $size .. $#{$self->{ARRAY}} + $size ]
298 :               $self->STORE( $_, $list[$_] ) foreach 0 .. $#list;
perlintro.pod
125 :         The special variable $#array tells you the index of the last element of an array:
127 :          print $mixed[$#mixed];       # last element, prints 1.23
129 :         You might be tempted to use "$#array + 1" to tell you how many items there are in an array. Don't bother. As it happens, using @array where Perl expects to find a scalar value ("in scalar context") will give you the number of elements in the array:
139 :          @animals[1..$#animals];        # gives all except the first element
perldiag.pod
159 :             $r = do {my @a; \$#a};
1353 :     $# is no longer supported
1354 :         (D deprecated, syntax) The special variable $#, deprecated in older perls, has been removed as of 5.10.0 and is no longer supported. You should use the printf/sprintf functions instead.
2639 :         (W misc) You attempted to specify an offset that was past the end of the array passed to splice(). Splicing will instead commence at the end of the array, rather than past it. If this isn't what you want, try explicitly pre-extending the array by assigning $#array = $offset. See "splice" in perlfunc.
perldata.pod
17 :         $#days              # the last index of array @days
143 :     The length of an array is a scalar value. You may find the length of array @days by evaluating $#days, as in csh. However, this isn't the length of the array; it's the subscript of the last element, which is a different value since there is ordinarily a 0th element. Assigning to $#days actually changes the length of the array. Shortening an array this way destroys intervening values. Lengthening an array that was previously shortened does not recover values that were in those elements.
148 :         $#whatever = -1;
152 :         scalar(@whatever) == $#whatever + 1;
perltrap.pod
55 :               ARGC      scalar @ARGV (compare with $#ARGV)
60 :               NF        $#Fld, or some such
62 :               OFMT      $#
112 :     *   To iterate over the indices of an array, use "foreach my $i (0 .. $#array) {}". "foreach my $v (@array) {}" iterates over the values.
perlguts.pod
264 :     The "av_top_index" function returns the highest index value in an array (just like $#array in Perl). If the array is empty, -1 is returned. The "av_fetch" function returns the value at index "key", but if "lval" is non-zero, then "av_fetch" will store an undef value at that index. The "av_store" function stores the value "val" at index "key", and does not increment the reference count of "val". Thus the caller is responsible for taking care of that, and if "av_store" returns NULL, the caller will have to decrement the reference count to avoid a memory leak. Note that "av_fetch" and "av_store" both return "SV**"'s, not "SV*"'s as their return value.
746 :      #  PERL_MAGIC_arylen         vtbl_arylen    Array length ($#ary)
perlop.pod
593 :         @foo = @foo[0 .. $#foo];        # an expensive no-op
594 :         @foo = @foo[$#foo-4 .. $#foo];  # slice last 5 items
perlref.pod
433 :       $aref->$#*; # same as $#{ $aref }
perlretut.pod
474 :         foreach $exp (1..$#-) {
perlebcdic.pod
561 :         @alphabet = ('A'..'Z');   #  $#alphabet == 25
<< Back to Perldoc Search