-print STDERR "Creating table template... ";
-@body = ('','$names{$u}','$forms{$u}','$addresses{$u}');
-for ($a=0;$a<$theory+$praxis;$a++) {push @body,"\$tasks{\$u}{$a}";}
-print STDERR "OK\n";
-
-print STDERR "Filling in results... ";
-@table = ();
-foreach $u (keys %users) {
- next unless defined $names{$u}; # don't show any user not defined in teorie.txt
- $row = [];
- $row_index=0;
- $row_sum=0;
- foreach my $c (@body) {
- $c =~ s/\$(\d+)/\$\$row[$1]/g;
- $x = eval $c;
- push @$row, (defined $x ? $x : '-');
- if ($row_index>3) {
- if ((defined $x) && ($x>0)) {$row_sum+=$x;}
- }
- $row_index++;
- }
- push @$row, $row_sum;
- push @table, $row;
-}
-print STDERR "OK\n";
-
-print STDERR "Sorting... ";
-$sortcol = @{$table[0]} - 1;
-$namecol = 1;
-@table = sort {
- my $p, $an, $bn;
- $p = $$b[$sortcol] <=> $$a[$sortcol];
- ($an = $$a[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
- ($bn = $$b[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
- $p ? $p : ($an cmp $bn);
-} @table;
-$i=0;
-while ($i < @table) {
- $j = $i;
- while ($i < @table && ${$table[$i]}[$sortcol] == ${$table[$j]}[$sortcol]) {
- $i++;
- }
- if ($i == $j+1) {
- ${table[$j]}[0] = "$i.";
- } else {
- ${table[$j]}[0] = $j+1 . '.' . $pos_delim . $i . ".";
- $j_old=$j;
- $j++;
- while ($j < $i) { ${table[$j++]}[0] = $j_old+1 . '.' . $pos_delim . $i . "."; };
- }
+print STDERR "Generating output... ";
+for my $u (sort keys %users) {
+ print join("\t", $u, $users{$u}, map { $tasks{$u}{$_} // '-' } @ARGV), "\n";