diff tabular2HTML.pl @ 0:a5814dd5a11a default tip

Uploaded
author ondovb
date Fri, 23 Sep 2011 17:06:15 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tabular2HTML.pl	Fri Sep 23 17:06:15 2011 -0400
@@ -0,0 +1,69 @@
+
+use strict;
+
+my ($table, $input, $output, @spans) = @ARGV;
+
+# positions that should have dark right borders
+#
+my %dark;
+
+foreach my $span ( @spans )
+{
+	if ( $span > 1 )
+	{
+		# only initialize if there are any spans more than 1
+		
+		pop @spans;
+		my $i;
+		
+		foreach my $span ( @spans )
+		{
+	    	$i += $span;
+		    $dark{$i - 1} = 1;
+		}
+		
+		last;
+    }
+}
+
+open TABLE, ">>$table" or die $!;
+open INPUT, "<$input" or die $!;
+
+my $parity;
+
+while ( my $line = <INPUT> )
+{
+	chomp $line;
+	
+	my @vals = split /\t/, $line;
+	
+	$parity = ( $parity eq 'odd' ? 'even' : 'odd' );
+	
+	print TABLE "<tr class='$parity'>";
+	
+    for( my $i = 0; $i < @vals; $i++ )
+    {
+		my $val = $vals[$i];
+		my $class;
+	
+		if ( $dark{$i} )
+		{
+			$class = ' class="darkRight"';
+		}
+	
+		$val =~ s/</&lt;/;
+		$val =~ s/>/&gt;/;
+	
+		print TABLE "<td$class>$val</td>";
+	}
+	
+	print TABLE "</tr>\n";
+}
+
+close INPUT;
+
+print TABLE "</table></body></html>\n";
+
+close TABLE;
+
+`mv $table $output`;