An array in Perl is a variable used to store an ordered list of scalar values. An array variable is preceded by an “at” (@) sign. The size of an array can be determined using the scalar context on the array which returns the number of elements in the array
Size of the Array is 3
Above code returns the physical size of the array, not the number of valid elements. In order to obtain the maximum index of an array, ‘$#’ is used as shown in the example below:
Array is 1 2 3 20 Maximum index is 15
Here is how the above code works:-
Step1: Initializing an array with some values
Step2: Assigning a value at any random index leaving the other indices blank
Step3: Printing the array to show the blank spaces left in the array
Step4: To get the maximum index ‘$#’ is used
Step5: Further, print the maximum index
- Perl | Array pop() Function
- Perl | Reverse an array
- Perl | Number and its Types
- Number Guessing Game using Perl
- Perl | Automatic String to Number Conversion or Casting
- Elements that occurred only once in the array
- Reset keys of array elements using PHP ?
- Program to remove empty array elements in PHP
- How to get specific number of child elements using CSS?
- Perl vs C/C++
- Perl | hex Function
- Perl | uc() Function
- Perl | chr() Function
- Perl | tell() Function
- Perl | y Operator
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.