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