Family Origins Export.pl
From Organic Design wiki
#!/usr/bin/perl -w
use Cwd;
open(FO, '<', cwd.'/family-tree.txt') or die "Can't open 'FO'!";
open(INDEX, '>', cwd.'/exported/index.txt') or die "Can't open 'INDEX'!";
$i = 0;
while (<FO>) {
if (/^(.*),\s*(.+?)\s+\(([MF ]+)\)/) {
($surname, $name, $sex) = ($1, $2, $3);
$surname =~ s/[\"]/\'/g;
$surname =~ s/[\(\)?\\\/:]//g;
$name =~ s/[\"]/\'/g;
$name =~ s/[\(\)?\\\/:]//g;
print "$surname,$name\n";
close FILE;
open (FILE, '>', cwd."/exported/$surname,$name.txt") or die "Couldn't open '$surname,$name.txt'!";
print FILE "sex:$sex\n";
print INDEX "$surname,$name\n";
$i++;
}
if (/^\t(.+)\t(.+)$/) { print FILE "$1:$2\n" }
}
close FO;
close FILE;
close INDEX;
print "\n\n$i entries found.\n";