Wednesday, 4 November 2009

list definition

A list is defined as collection of elements. Elements can be assigned to the list just like a scalar assignment.

Example :

($a,$b,$c) = (1,2,3) or ($1..$2) = ($a..$z)
same thing can be written as ($a,$b,$c) = qw(1 2 3 ).

An array doesnot become an element in the list, as the array contains scalars only.Just as empty scalar variables start out with undef, empty arrays startout with empty list.

Array elements :

$fruit[1] = "apple" ; $fruit[2] = "banana" ;
same as :
@fruit = ("apple" , "banana");

No comments:

Post a Comment

Tweets by @sriramperumalla