[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Benchmark transcription file
Hi everyone,
Here's [version 0.001 of] some Perl I just hacked together to convert a
non-interlinear EVT file into JavaScript: it's pretty straightforward
(unnecessarily complex code always brings me out in a rash), so should be
easy to adapt to whatever nefarious purposes you desire. :-)
Any errors/omissions/oversights are (of course) solely mine: please trumpet
them loudly here on the list so that I feel embarrassed enough to fix them
quickly. :-)
Cheers, .....Nick Pelling.....
* * * * * * *
$line = <STDIN>; chop ($line);
while ($line ne "")
{
$line =~ /\<f([0-9]+[rv][0-9]*)[\.]*(.*)\> +(.*)/;
$page = $1; $part = $2; $main = $3;
if ($part eq "")
{
$spec = (($main =~ /I[\=]([A-Z0-9])/) ? $1 : " ");
$spec .= (($main =~ /Q[\=]([A-Z0-9])/) ? $1 : " ");
$spec .= (($main =~ /P[\=]([A-Z0-9])/) ? $1 : " ");
$spec .= (($main =~ /L[\=]([A-Z0-9])/) ? $1 : " ");
$spec .= (($main =~ /H[\=]([A-Z0-9])/) ? $1 : " ");
$spec .= (($main =~ /X[\=]([A-Z0-9])/) ? $1 : " ");
print ("f(\"", $page, "\",\"", $spec, "\");\n");
} else {
$part =~ /(.*);[A-Z]/; $part = $1;
$main =~ s/[\!]+//g;
while ($main =~ /\&([0-9]+);/)
{
$num = sprintf("%02X", $1);
$main =~ s/\&0*([0-9])+;/\\x$num/;
}
print ("p(\"", $part, "\",\"", $main, "\");\n");
}
$line = <STDIN>; chop ($line);
}