in reply to Complex Sorting/Reporting
foreach $item (sort @items) { @tmp= split (/!/, $item, 16); push (@test, @tmp); push @AoA, [ @tmp ]; } print "\n"; # Print the whole thing, one at a time. print "COMP7650 :\n"; print "_____________________\n"; for $i (0..$#AoA) { print "$class{$AoA[$i][0]} \n\t $student{$AoA[$i][0]}\n"; for $j (0..$#{ $AoA[$i] }) { if ($j eq 1) { print "\t\t\t- $AoA[$i][1]\n"; } } }
In the above code i made an Array of array which holds the
values from the student-information file.
I also made a a hash for each of the items i want from the
student-file. somehing like so:
open (FILE, "student.data"); while (defined ($line = <FILE>)) { if ($line =~ /^(.*)!(.*)!(.*)!(.*)$/) { $id{$1} = $1; #id's $student{$1} = $2; $major{$1} = $3; $status{$1} = $4; } } close (FILE);
The structure now looks like this (using Data::Dumper):
$students = [ [ '45623456', 'COMP8769', 'A', 'Dr.Smith', 'MWF', '10:00', ], [ blah, blah, blah.. ] ];
THe output for all of this is clear by looking at the for loop . I was able to sort by class but is still need to sort to look somthing like => sort by each attribute in student-info-row->Major->sort by student->info.
I was wondering if i could do something like HoH->HOH->HoA. Does anyone have suggestions. From the begining i wanted to do this without using a DBMS/SQL but now i am this close to giving up on using complex data sturcture to do this. Any help will be most appreciated.
|
|---|