On Mon, 18 Jun 2001, Gary Stainburn wrote:

> > actualy that would be a pointer from @array1 -> @array2 correct?
>
> Yup, although in Perl they're called references. There is a difference but I
> can't remember what it is.

The biggest difference is that in C, you have to allocate memory before
you can point at something or you will get a null pointer exception, and
then deallocate the memory when you are done.  Perl does this
automagically.

> The syntax would be:
>
> @array2 = { bah, \@array1, blah, blah }

Careful -- use parentheses here, not braces.

> Then to access array1 again, you could use @${array2[1]} or an element in
> array1 as ${$array2[1]}[x].

I would suggest also, especially for beginners, to use the infix arrow
syntax -- it makes things a little clearer, especially when you get into
multidimensional arrays (and using references is the nly way to do so).

$array2[1]->[$x];

-- Brett

                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
I hope you millionaires are having fun!  I just invested half your life
savings in yeast!!

Reply via email to