Hi,
I've playing around with a multidimensional array and found something that confusses me royally.
What is so special about
$a_final[1][1][0][0] in the following snippet?
I can assign all the other elements (or at least, all I've tested).
But not this one.
Can you help me?
Thank you very much.
burgerw
@a_1 = ();
@a_2 = ();
@a_3 = ();
@a_4 = ();
@a_a = (\a_4, \a_3);
@a_b = (\@a_2, \a_a);
@a_final = (\@a_1, \@a_b);
#These do work:
$a_final[0][1][0][0] = "x";
print "$a_final[0][1][0][0]\n";
$a_final[1][0][0][0] = "x";
print "$a_final[1][0][0][0]\n";
$a_final[1][2][0][0] = "x";
print "$a_final[1][2][0][0]\n";
# This won't work:
# error message: "Not an ARRAY reference"
$a_final[1][1][0][0] = "x";
print "$a_final[1][1][0][0]\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.