I'm not entirely sure what your question is, or where the confusion lies. Could you clarify?
As I said above, references are sort of like pointers in C, if you're familiar with that. A data structure lives somewhere in memory; another variable, a scalar (which might in turn be an element of an array or hash, of course) holds a reference to it. A redirect, if you will: "the data you're looking for is found in another location. Walk this way!"
Programming Perl has an entire chapter on references, so if you've got that book, I'd read that. (If you don't have that book, buy it, it's a must-have for any Perl programmer.) Also, see perlref for a less gentle introduction.
Anyhow, to sum it up:
- $row contains (colloquially: is) a reference to an array, i.e. the one that split returns.
- That array does not have a name of its own; i.e., it's not @array or any such thing.
- However, you can use the reference in $row -- "walk this way", as it were, following the directions it contains -- by dereferencing the reference. For an array reference, this is done by adding the array sigil, @: @$row.
- The same applies to $sheet2 and @$sheet2.
- Finally, @$sheet2 -- an array, remember! -- is used to store a list of references, each of which points to another array: one for each row.
So you have something like this for each line:
$row @$row
+---+ +-----+-----+-----+--
| *-----> | ... | ... | ... | ...
+---+ +-----+-----+-----+--
and something like this for the entire file:
$sheet2 @$sheet2 (each of the @$row's)
+---+
+---+ | | +-----+-----+-----+--
| *-----> | *-----> | ... | ... | ... | ...
+---+ | | +-----+-----+-----+--
+---+
| | +-----+-----+-----+--
| *-----> | ... | ... | ... | ...
| | +-----+-----+-----+--
+---+
| . |
.
Does that make it clearer?
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.