annotate tabular2HTML.pl @ 0:a5814dd5a11a default tip

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