The Array Size Indicator : Array Length « Array « Perl

Home
Perl
1.Array
2.CGI
3.Class
4.Data Type
5.Database
6.File
7.GUI
8.Hash
9.Language Basics
10.Network
11.Regular Expression
12.Report
13.Statement
14.String
15.Subroutine
16.System Functions
17.Win32
18.XML
Perl » Array » Array Length 




The Array Size Indicator
   

$9999;      #This loop doesn't run because @checksThisMonth returns the array size, which is less than 1501.

for ($i = $[;               #initialization list
     $i < @checksThisMonth; #conditional expression
     $i++){                 #increment list

   print "$checksThisMonth[$i]";

}

#This loop runs because $#checksThisMonth returns the last cell index.

for ($i = $[; $i <= $#checksThisMonth; $i++){
    print "$checksThisMonth[$i]";
}

   
    
    
  














Related examples in the same category
1.Using a $#array variable in a loop.
2.Get array length
3.$# is the array size
4.$#questions is the index of the highest element in the @questions array.
5.Change array length by assigning new length to an array
6.Change array length by adding new element to an array
7.Get the array length by assigning the array variable to a scalar variable
8.Increase the number of elements to 11
9.Reducing the number of elements to 6
10.Using scalar function to get the array length
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.