Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: What is the difference between a list and an array?

by mischief (Hermit)
on Dec 11, 2001 at 19:24 UTC ( #130943=note: print w/ replies, xml ) Need Help??


in reply to What is the difference between a list and an array?

Hello,

There is a good explanation in perlfaq4:

       What is the difference between a list and an array?
An array has a changeable length. A list does not. An array is something you can push or pop, while a list is a set of values. Some people make the distinction that a list is a value while an array is a variable. Subroutines are passed and return lists, you put things into list con- text, you initialize arrays with lists, and you foreach() across a list. "@" variables are arrays, anonymous arrays are arrays, arrays in scalar context behave like the num- ber of elements in them, subroutines access their argu- ments through the array "@_", and push/pop/shift only work on arrays. As a side note, there's no such thing as a list in scalar context. When you say $scalar = (2, 5, 7, 9); you're using the comma operator in scalar context, so it uses the scalar comma operator. There never was a list there at all! This causes the last value to be returned: 9.


Comment on Re: What is the difference between a list and an array?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://130943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2015-07-05 15:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls