N/APosted on - 01/20/2012
Can anyone please tell me the difference between @array and $array.
I need help to make an array of arrays and recursive data types.
Is it possible to make an array of structures which contains various data types?
Thanks so much for the help.
What is the Difference between @array and $array
The former is a scalar value, the latter an array slice, which makes it a list with one (scalar) value. You should use $ when you want a scalar value (most of the time) and @ when you want a list with one scalar value in it (very, very rarely; nearly never, in fact).
Sometimes it doesn't make a difference, but sometimes it does. For example, compare:
$good = `some program that outputs several lines`; with
@bad = `same program that outputs several lines`;
The -w flag will warn you about these matters.
I hope it helps,