Javatpoint Logo
Javatpoint Logo

Perl Multidimensional Array

Perl multidimensional arrays are arrays with more than one dimension. The multi dimensional array is represented in the form of rows and columns, also called Matrix.

They can not hold arrays or hashes, they can only hold scalar values. They can contain references to another arrays or haashes.


Perl Multidimensional Array Matrix Example

Here, we are printing a 3 dimensional matrix by combining three different arrays arr1, arr2 and arr3. These three arrays are merged to make a matrix array final.

Two for loops are used with two control variables $i and $j.

Output:

Print Using Array Index
0 10 0
0 0 20 
30 0 0

Perl Multidimensional Array Initialization and Declaration Example

In this example we are initializing and declaring a three dimensional Perl array .

Output:

1 2 3
4 5 6 
7 8 9
Next TopicPerl String




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA