ak |;
use Data::Dump qw| dump |;
use Encode qw| encode_utf8 |;
use IO::Handle;
use JSON::XS qw| decode_json |;
use Sys::Cmd qw| spawn |;
use Try::Tiny;
sub read_games {
my $pgn = shift;
xtract', '-s', '-Wjson', $pgn );
my $out = do { local $/; $proc->stdout->getline };
my @err = $proc->stderr->getlines;
if (@err) {
if ($err[0] =~ /Unknown output format json/) {
croak
r: pgn-extract has no '-Wjson' option");
}
STDERR->print ("pgn-extract: $_") for @err;
}
$proc->wait_child; # cleanup
# Ad-hoc hack for a problem in parsing JSON
#
# PGN files may c