Date: Sun, 09 Sep 2001 11:59:50 GMT From: Sudhir Krishnan Subject: Arrays, References and indexes. Message-Id: <3B9B5A80.9D2198E3@newmail.net> Hi, I've been using perl since a week. I need to read in a number of files and use an appropriate data-structure for the same. Each file is divided into a number of sections. Each line will be a record file 1 file 2 file 3 [ ] [ ] [ ] [ ] [ ] [ ] --- --- --- [ ] [ ] [ ] [ ] [ ] [ ] ---- ---- ---- [ ] [ ] [ ] [ ] [ ] [ ] Something like a triple dimensional array seems to suit the purpose. a[i][j][k]; i=file index j=section index in file k=line (record) index in (file, section) While iterating over the files, I'm storing it as: a[i][j][k] = $_; And it seems to work fine. Problems: 1) I don't really understand the underlying implementation with references. 2) I use a[i][j][k] for getting/setting values, its 3 loops and is cumbersume. 3) I'd like to know how I can get/set values without using indexes. i.e for a simple array: instead of for ($i=0; $i <=$#ARR; $i++) I'd like to use for $val (@ARR) But in my case, $val will be a reference until I read the 3rd level, right? Sample code would be really appreciated!! thanks! Sudhir