Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use lists and arrays in perl

Shulou Source: shulou.com Published: 2022-06-01 12:38:24 09月13日 Update

This article will explain in detail how to use lists and arrays in perl. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Lists and arrays in perl

A list is a collection of scalars, and an array is a variable that stores a list.

Examples are as follows:

(1, 2, 3, 4) it's a list.

You can assign a value to an array @ array= (1, 2, 3, 4)

(5, 6, 7, 8) is a list.

You can also assign a value to the array @ array= (5, 6, 7, 8)

The above two @ array are the same array, but different lists refer to specific data, while the array is just a variable and can hold different lists.

I. list

A list is a sequence of values contained in parentheses, which can be any numeric value or empty, such as: (1,5.3, "hello", 2), empty list: ().

Note: a list with only one value (for example: (43.2)) is different from the value itself (that is, 43.2), but they can be converted or assigned to each other. List example:

(17, $var, "a string") (17, 26

Tags: Arrays elements variables characters scalars indexes differences strings expressions results quantities parentheses length upper and lower context functions parameters quotation marks order input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei Docker Shulou Tech Info MySQL