#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Encode qw/encode decode/;
use Date::Calc qw(Date_to_Days Today);
my @buf = ();
my $c = 0;
my $d = 0;
my %num = ();
my $before = '';
print encode('utf8','
');
print encode('utf8','');
print encode('utf8','');
print "\n";
while (<>) {
chomp;
(
$buf[$c]->{year},
$buf[$c]->{month},
$buf[$c]->{day},
$buf[$c]->{course},
$buf[$c]->{turf},
$buf[$c]->{distance},
$buf[$c]->{condition},
$buf[$c]->{name},
$buf[$c]->{sex},
$buf[$c]->{age},
$buf[$c]->{record},
$buf[$c]->{alert},
$buf[$c]->{diff},
$buf[$c]->{ketto_toroku_bango},
) = split(/\,/,$_);
if ($before ne $buf[$c]->{name}) {
print "- ".$buf[$c]->{name}."
\n";
$before = $buf[$c]->{name};
$d++;
}
$c++;
}
$buf[$c]->{diff} = '----';
$buf[$c]->{name} = 'Dummy';
print "
\n";
$before = $buf[0]->{name};
my $tx = '';
my $ty = '';
my $tz = '';
my $tc = 0;
my $dx = '';
my $dy = '';
my $dz = '';
my $dc = 0;
$d = 0;
for (my $i = 0; $i < $c+1; $i++) {
if ($before ne $buf[$i]->{name}) {
print "\n
{ketto_toroku_bango}."\">$before
\n";
$before = $buf[$i]->{name};
$d++;
if ($tx eq '') {
$tx = -1;
$ty = -1;
$tz = 0;
}
chart($tx,$ty,$tz);
if ($dx eq '') {
$dx = -1;
$dy = -1;
$dz = 0;
}
chart($dx,$dy,$dz);
$tx = '';
$ty = '';
$tz = '';
$tc = 0;
$dx = '';
$dy = '';
$dz = '';
$dc = 0;
}
next if (($buf[$i]->{diff} eq '----') || ($buf[$i]->{year} eq ''));
$buf[$i]->{distance} = 1200 if ($buf[$i]->{distance} < 1200);
my $sx = int(($buf[$i]->{distance} - 1200)/200);
$sx *= 3;
my $sy = $buf[$i]->{diff} * 50;
$sy = 0 if ($sy < 0);
$sy = 100 if ($sy > 100);
my $sz = Date_to_Days($buf[$i]->{year}+2000,$buf[$i]->{month},$buf[$i]->{day});
$sz = Date_to_Days(Today()) - $sz;
$sz = int((1000 - $sz) / 1000 * 10);
$sz = 3 if ($sz < 3);
if (decode('utf8',$buf[$i]->{turf}) eq "芝") {
#芝
my $ssx = 0;
if (decode('utf8',$buf[$i]->{course}) eq '中山' || decode('utf8',$buf[$i]->{course}) eq '阪神') {
$ssx += 1;
if ($buf[$i]->{month} >= 1 && $buf[$i]->{month} < 9) {
$ssx += 1;
}
}
if ((decode('utf8',$buf[$i]->{course}) eq '函館') || (decode('utf8',$buf[$i]->{course}) eq '札幌')) {
$ssx += 1;
}
if ((decode('utf8',$buf[$i]->{condition}) eq '重') || (decode('utf8',$buf[$i]->{condition}) eq '不')) {
$ssx += 1;
}
$ssx = 2 if ($ssx > 2);
$sx += $ssx;
$sx *= 5;
$sx = 100 if ($sx > 100);
$tx .= "," if ($tx ne '');
$tx .= $sx;
$ty .= "," if ($ty ne '');
$ty .= 100 - $sy;
$tz .= "|" if ($tz ne '');
if ((decode('utf8',$buf[$i]->{course}) eq '東京') || (decode('utf8',$buf[$i]->{course}) eq '中山') || (decode('utf8',$buf[$i]->{course}) eq '阪神') || (decode('utf8',$buf[$i]->{course}) eq '京都') || (decode('utf8',$buf[$i]->{course}) eq '中京') || (decode('utf8',$buf[$i]->{course}) eq '小倉') || (decode('utf8',$buf[$i]->{course}) eq '新潟') || (decode('utf8',$buf[$i]->{course}) eq '福島') || (decode('utf8',$buf[$i]->{course}) eq '札幌') || (decode('utf8',$buf[$i]->{course}) eq '函館')) {
$sz = "o,00a000,0,$tc,".$sz;
} else {
$sz = "x,00a000,0,$tc,".$sz;
}
$tz .= $sz;
$tc++;
} else {
#ダート
my $ssx = 0;
if ((decode('utf8',$buf[$i]->{course}) eq '阪神') || (decode('utf8',$buf[$i]->{course}) eq '中山')) {
$ssx += 2;
}
if ((decode('utf8',$buf[$i]->{course}) eq '新潟') || (decode('utf8',$buf[$i]->{course}) eq '小倉') || (decode('utf8',$buf[$i]->{course}) eq '函館')) {
$ssx += 1;
}
if ((decode('utf8',$buf[$i]->{condition}) eq '重') || (decode('utf8',$buf[$i]->{condition}) eq '不')) {
$ssx -= 1;
}
if ((decode('utf8',$buf[$i]->{course}) eq '小倉') && (decode('utf8',$buf[$i]->{condition}) eq '稍')) {
$ssx -= 1;
}
$ssx = 2 if ($ssx > 2);
$ssx = 0 if ($ssx < 0);
$sx += $ssx;
$sx *= 5;
$sx = 100 if ($sx > 100);
$dx .= "," if ($dx ne '');
$dx .= $sx;
$dy .= "," if ($dy ne '');
$dy .= 100 - $sy;
$dz .= "|" if ($dz ne '');
if ((decode('utf8',$buf[$i]->{course}) eq '東京') || (decode('utf8',$buf[$i]->{course}) eq '中山') || (decode('utf8',$buf[$i]->{course}) eq '阪神') || (decode('utf8',$buf[$i]->{course}) eq '京都') || (decode('utf8',$buf[$i]->{course}) eq '中京') || (decode('utf8',$buf[$i]->{course}) eq '小倉') || (decode('utf8',$buf[$i]->{course}) eq '新潟') || (decode('utf8',$buf[$i]->{course}) eq '福島') || (decode('utf8',$buf[$i]->{course}) eq '札幌') || (decode('utf8',$buf[$i]->{course}) eq '函館')) {
$sz = "o,a00000,0,$dc,".$sz;
} else {
$sz = "x,a00000,0,$dc,".$sz;
}
$dz .= $sz;
$dc++;
}
}
print encode('utf8','');
sub chart {
my ($x,$y,$z) = @_;
print "
");
}