in reply to Re: What is the difference between $array[1] and @array[1]?
in thread What is the difference between $array[1] and @array[1]?
Also, @array[1] drives a list context whereas $array[1] would drive scalar context. Hence:
will behave differently than@array[1] = @another_array;
The former will put the index (i.e., the number of elements in @another_array minus one) of the last element in @another_array in the first element of @array; whereas the second will put the number of elements in @another_array in the first element of @array.$array[1] = @another_array;
Similarly, if you use @array1 as input to a function that behaves differently in list context vs. scalar context, the use of @array[1] will result in list context behavior, whereas $array[1] will result in scalar context behavior (hence, actually, the differences shown above in my example).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: What is the difference between $array[1] and @array[1]?
by JavaFan (Canon) on Apr 09, 2009 at 14:07 UTC | |
|
Re^3: What is the difference between $array[1] and @array[1]?
by jethro (Monsignor) on Apr 09, 2009 at 13:27 UTC |