Multidimensional Arrays

Let's learn what multidimensional arrays are and learn how to access elements stored in an array in this lesson.

What are multidimensional arrays?

Perl allows us to create multidimensional arrays. We can think of these arrays as an extension of the single-dimensional (linear) arrays. For example, two-dimensional arrays can be imagined as a matrix or table containing two dimensions: rows and columns.

Similarly, three-dimensional arrays can be imagined as a cube with three dimensions. Each dimension is represented using [], with the indices starting from 0 along each dimension. The size of arrays can grow dynamically. Values stored in multidimensional arrays can be of any data type. In the example below, we consider strings:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy