Ok, step by step, your @data contains *references* to arrays. $#array
designates the last addressible index of an array (!not the size!), making a
standard iteration over the entire array to look like for($i = 0; $i *<=*
$#array, $i++)
So, what happens is that you iterate over the entire array. Then, you
dereference each element of the @data array by forcing the scalar element to
act as an array, and then once again you get the size of each array
contained as an element of @data ($#{$data[i]}), {} force $data[i] to be an
array, then standard $#.
-----Original Message-----
From: Michael Carmody [mailto:[EMAIL PROTECTED]]
Sent: 06 e?iy 2001 a. 20:36
To: [EMAIL PROTECTED]
Subject: It works but I dont get it...
Been working on parsing a data file to create a ldif file for openldap.
Managed to read everything in to an AoA Ok but printing the output ha sbeen
a headache.
Finally just copy and pasted from manual the print individual entry of AoA
example, and of course it worked. But I don't understand why.
#This part of the code i'm happy with
open (ADDSRC, "test.csv") || die ("Unable to open file\n");
@addsrc=<ADDSRC>;
#splice (@addsrc,0,1);
foreach $line (@addsrc)
{
@addarr = split(/,/, $line);
push @fname, $addarr[0];
push @sname, $addarr[1];
push @email, $addarr[2];
push @exten, $addarr[3];
push @hom_ph, $addarr[4];
chomp $addarr[5];
push @section, $addarr[5];
}
@data = (\@fname, \@sname, \@email, \@exten, \@hom_ph, \@section);
#alright now to print the sucker
for $i ( 0 .. $#data )
{
for $j ( 0 .. $#{ $data[$i] } )
{
print "elt $i $j is $data[$i][$j]\n";
}
}
What I need help with is the meaning of $#data ?, I assume 0 .. $#data
means to go from element 0 to end of array but how exactly is this done ?
Also why any of the brackets are where they are. probably all for good
reasons but i just don't get it at the moment.
Michael Carmody
MDU, Public Health Lab
Dept. of Microbiology and Immunology
The University of Melbourne, Parkville