How to Declare an Array in Perl Functions
Perl is an open-source language that enables you to program on various platforms, including Unix, Mac and Windows. Arrays are a programming construct that enables you to store lists or related content. Perl arrays are defined with a preceding "@" sign. Each element is contained within a parenthesis and separated by commas. Insert string data within quotes and numerical data without the quotes.
Instructions
-
-
1
Open your Perl document in a Perl or text editor.
-
2
Type the following code to define a numerical array:
@nums = (1,20,3,45);
-
-
3
Type the following code to define an array that contains strings:
@mystr = ("me","myself","I");
-
4
Insert the following data to define an array consisting of numbers and strings:
@alphanum = ("once",5,"always",2,6);
-
1
References
Resources
- Photo Credit Jupiterimages/Photos.com/Getty Images