#!/usr/bin/perl -w ($template,$input,$output) = ($ARGV[0],$ARGV[1],$ARGV[2]); unless (defined($template) && defined($output) && defined($input)) { die(" use:\n dict.pl template input output\n"); } open(TEX,$template) || die("Not able to make filehandle: $!\n"); open(SAIDA,">$output") || die("Not able to make filehandle: $!\n"); open(INP,$input) || die("Not able to make filehandle: $!\n"); $tex = ; while (!($tex =~ m/\%END/)) { print SAIDA $tex; $tex = ; } $linha = 0; while ($inp = ) { chomp($inp); if ($inp =~ m/START\*/) { $linha = 1; undef(@back); undef($front); } elsif ($inp =~ m/END/ && $linha > 0) { $linha = 0; print SAIDA "\n" . '\begin{flashcard}{' . $front . '}' . "\n"; for $line (@back) { print SAIDA " " . $line; } print SAIDA "\n" . '\end{flashcard}' . "\n" } elsif ($linha > 0) { $linha++; } if ($linha == 2) { $front = $inp; $front =~ s/"-/\$\\ddot{-}\$/g; $front =~ s/([^{])-([^}])/$1\$-\$$2/g; $front =~ s/\|/\$\\vert\$/g; } elsif ($linha > 2) { $i = $linha - 2; $inp =~ s/\{(\w\w)\s([^{}]*)\}/\\sel$1\{$2\}/g; $inp =~ s/~/\$\\sim\$/g; $inp = " " . $inp; $back[$i] = "$i)" . $inp; } } print SAIDA "\n" . '\end{document}' . "\n"; close(SAIDA); close(TEX); close(INP);