Tarscher said:
I have been looking for this on the net but I didn't found an answer.
Maybee you guys can help me out?
I m using GD to create charts and have to use the $graph->plot(\@data)
command somewhere. The \@ interests me and I don't know why I can just
use $ or @ ?
Because they are vastly different things.
@data is an array named 'data'
$data is a scalar variable named 'data'
Other than their names, @data and $data have NOTHING to do with one
another. Not even a little bit.
\@data is a reference to the array named @data. It is a single scalar
value. It references the array @data.
To answer your question about why you have to pass a reference to @data
rather than @data itself, the simple answer is "That's how the module
designer created it.". *Why* he/she created it that way is an answer I
cannot give without digging into the module. A likely possibility is
that the method in question wants/needs to directly modify the array
that it wants passed in. While possible to do without references,
this is much cleaner to do with references.
For more information on references, please read:
perldoc perlreftut
perldoc perllol
perldoc perldsc
perldoc perlref
For more information on subroutines and their arguments, please read:
perldoc perlsub
Paul Lalli