
KevinR
Veteran

Jan 8, 2009, 9:38 AM
Views: 474
|
i understand the following $ is for scalar @ is for array what's the difference between @ary[0] and $ary[0] The difference is the first one is in list context and the second one is in scalar context. The first one is also a deprecated form of the second one from earlier versions of perl. The first one can return many values: @list = @array[1,4,3,2,6]; the second one is a scalar and can return only one value: $value = $array[0]; Using the proper context is important as it affects the value returned depending on what you are doing or what function you are using to process a list or scalar. -------------------------------------------------
(This post was edited by KevinR on Jan 8, 2009, 9:40 AM)
|