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

use strict;

my $line;

open(OUTPUT, ">  finaltab.txt") || die("can't open  finaltab.txt");
open (FILE, "wikitext.txt") || die "Can't open tab.txt.\n";
$/ = "\n";
while(<FILE>){
     $line = $_;
	$line =~s/\|-\n//;
	$line =~s/\|\|/\t/;
	$line =~s/\|//;
	$line =~s/!//;
	$line =~s/}//;
	$line =~s/{.*//;
	$line =~s/\|}//;
	print OUTPUT "$line";
}

close FILE;
	
print "Finished";	
	
getc();