Gavilan

CSIS054: Perl Programming

Questions for week 5

 

QUESTION ANSWER
(highlight to read)
What is another word for a list? An array.
How do I create a list? With parentheses, like this:
@stuff = ("one", "two", "three");
How do I access an item in a list? With square brackets, like this:
print $stuff[1];
What is the sigil for a list variable? Ampersand (@).
What sigil do I use if I'm accessing a single item in a list? Dollar sign ($).
What do the following functions do: split, join see perlfunc
What do the following functions do: push, pop See perlfunc
What do the following functions do: sort, reverse See perlfunc
What does it mean to take a slice of a list? To extract a subset of the list.
How do I take a slice of a string? substr($str,$offset,$len);
How do I get the length of a list? length(@list);
 How do I produce a list of consecutive numbers?
 @list = 1..10;
   

 

 

 



Address of this page is http://hhh.gavilan.edu/phowell/csis054/05questions.html
Please contact Peter Howell at phowell@gavilan.edu for questions or comments.
Last updated January 10, 2010.