0
|
1
|
|
2 use strict;
|
|
3
|
|
4 my ($table, $input, $output, @spans) = @ARGV;
|
|
5
|
|
6 # positions that should have dark right borders
|
|
7 #
|
|
8 my %dark;
|
|
9
|
|
10 foreach my $span ( @spans )
|
|
11 {
|
|
12 if ( $span > 1 )
|
|
13 {
|
|
14 # only initialize if there are any spans more than 1
|
|
15
|
|
16 pop @spans;
|
|
17 my $i;
|
|
18
|
|
19 foreach my $span ( @spans )
|
|
20 {
|
|
21 $i += $span;
|
|
22 $dark{$i - 1} = 1;
|
|
23 }
|
|
24
|
|
25 last;
|
|
26 }
|
|
27 }
|
|
28
|
|
29 open TABLE, ">>$table" or die $!;
|
|
30 open INPUT, "<$input" or die $!;
|
|
31
|
|
32 my $parity;
|
|
33
|
|
34 while ( my $line = <INPUT> )
|
|
35 {
|
|
36 chomp $line;
|
|
37
|
|
38 my @vals = split /\t/, $line;
|
|
39
|
|
40 $parity = ( $parity eq 'odd' ? 'even' : 'odd' );
|
|
41
|
|
42 print TABLE "<tr class='$parity'>";
|
|
43
|
|
44 for( my $i = 0; $i < @vals; $i++ )
|
|
45 {
|
|
46 my $val = $vals[$i];
|
|
47 my $class;
|
|
48
|
|
49 if ( $dark{$i} )
|
|
50 {
|
|
51 $class = ' class="darkRight"';
|
|
52 }
|
|
53
|
|
54 $val =~ s/</</;
|
|
55 $val =~ s/>/>/;
|
|
56
|
|
57 print TABLE "<td$class>$val</td>";
|
|
58 }
|
|
59
|
|
60 print TABLE "</tr>\n";
|
|
61 }
|
|
62
|
|
63 close INPUT;
|
|
64
|
|
65 print TABLE "</table></body></html>\n";
|
|
66
|
|
67 close TABLE;
|
|
68
|
|
69 `mv $table $output`;
|