[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Multidimensional array question



I realize that this is not a Mac questions, but.....

What is with the "#" in the statements below?  I know that # usually means comment,
but I do not understand how it is being used here.  Any help with this would be
greatly appreaciated.  Thanks.

Mark Manning/Simulacron I wrote:

> Hello everyone!  :-)
>
> Question about multidimensional arrays.  I believe I know the answer to
> this but want to make sure.
>
> Why does:
>
>         $a[++$#a][0] = x;
>         $a[$#a][1] = y;
>
> Not work?  I get back:
>
>         ARRAY(blah,blah,blah)
>
> instead of the value of "x".
>
> My theory is that with multidimensional arrays you have to do the
> increment outside of the array because otherwise the pointers are not in
> place before the values are used.  Like so:
>
>         $#a++;
>         $a[$#a][0] = x;
>         $a[$#a][1] = y;
>
> At least, the first example gives me back that ARRAY stuff and the
> second one gives me back my values.
>
> TIA!  :-)
>
> --------------------------------------------------------------------------------
> All e-mail needs to be sent to mark@cheers.jsc.nasa.gov.  If you don't,
> it will
> probably bounce.  What man does not understand or fears; he ultimately
> destroys.
> Steve Wright: Black holes are where God divided by zero.
>
> ***** Want to unsubscribe from this list?
> ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch