in reply to difference between array and list in perl
Lists are really a special type of array - .essentially, , a list is a temporary construct that holds a series of values. The list can be "hand" generated using parentheses and the comma operator,
There are many definitions of list, so it's hard to describe what it is. Among other things, it can refer comma separated values in the source (a list literal), the operator produced by that code (a list operator) or the values the operator places on the stack (a list value).
On the other hand, the definition of array is quite clear. First and foremost, it's a type of variable. Very few if any properties are shared between arrays and lists (whichever definition you use) since lists are never variables in Perl.
Is it like when an array is created without any double quotes or single quotes, its called list ?
An array is never called a list. An array is never a list. It may return one. A list may be assigned to one.
In all of your examples, you are assigning a list to an array. You could also say you are initialising an array.
arrays lists vvvvvv vvvvvvvvvv @list1 = (1,2,3,4); @list2 = (list1, list2, list3, list4); @arr1 = ("1" , "2", "3", "4"); @arr2 = ("arr1", "arr2", "arr3", "arr4"); ^ assignments
|
|---|