next up previous contents
Next: Indexed Arrays Up: Arrays Previous: What is an Array?

Literal Arrays

Arrays can be defined literally in Perl code by simply enclosing the array elements in parentheses and separating each array element with a comma.

For example

(1, 2, 3)  
("fred", "albert")  
() # empty array (zero elements)
(1..5) # shorthand for (1,2,3,4,5)



dave@cs.cf.ac.uk