#!usr/bin/perl -w
#	
#	By Jennifer Deegan, 17th October, 2007
#
#	Converts tab-delimited text to wiki table.
# To run, type 'perl wikify_table.pl [filename]'
# on the command line, where 'filename' is the name of your
# tab-delimited file. 

use strict;

my $line;

open(OUTPUT, ">  wiki.txt") || die("can't open wiki.txt");
open (FILE, "tab.txt") || die "Can't open tab.txt.\n";
$/ = "\n";
print OUTPUT "{| border=\"1\" cellpadding=\"5\" cellspacing=\"0\"\n!";
while(<FILE>){
     $line = $_;
	$line =~s/\n/\n|-\n|/;
	$line =~s/\t/||/;
	print OUTPUT "$line";
}
print OUTPUT "\n|-\n\n|}";

close FILE;
	
getc();