
Associative array of a two dimensional array
: I am starting to go beyond my understanding of arrays. . .
You understand arrays just fine.
It is "references" that you don't understand.
They are explained in perlref.pod and perldsc.pod.
: I am making an associative array, each value of which contains a 2-D
: array.
You cannot do that in Perl.
Perl does not _have_ multi-dimensional arrays.
Perl *does* have arrays of references (possibly to another array),
which is how you get the *effect* of a 2D array.
This distinction is essential to understanding complex
data structures in Perl.
: This is what it looks like
: open FILE, "$file";
^ ^
You should always, yes *always*, check the return value from open():
open FILE, $file or die "could not open '$file' $!";
Your double quotes serve no purpose other than making it harder
to read.
You have not shared the subroutine declaration for your splics()
function.
You have another syntax error there too.
You are missing a semicolon.
We are obviously not looking at the same code that you are looking at.
Not much point in troubleshooting code that does not exist!
Do not type in code!!!
Use cut/paste!!!
Else you'll just get a bunch of wise ass remarks about your
typos instead of getting help with your real problem.
: again
: while (<FILE>) {
: }
^^^
Q: What context is that in?
A: scalar context
A: evaluates to the *number of elements* in the array
You are storing integers as the values of your hash.
You should be storing a reference to an array instead:
: close FILE;
: }
: (NOTE : FILE contains multiple columns of data :
: abc 123 234 324
: fds 123 321 234
: fdk 123 54 34
: )
In Perl, we say that as below, then everybody understands (even perl!)
and there is no ambiguity, plus others can run your code without
creating other files.
while (<DATA>) {
..
__DATA__
abc 123 234 324
fds 123 321 234
fdk 123 54 34
: later, I say
: 2-D array.
Because Perl does not *have* 2D arrays.
It has references to arrays...
: I don't really understand why.
... so you have to *de* reference it.
: Any insight would be
: wonderful.
Seek insight in the files that are already installed on your
hard disk.
--
Tad McClellan SGML Consulting
Fort Worth, Texas