From b220bfc7ee74d6a8ce1e7326cea4ed2014fec865 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 26 May 2011 00:24:27 +0200 Subject: [PATCH] tools/sgf2gtp.pl: Accept filename as optional argument --- tools/sgf2gtp.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/sgf2gtp.pl b/tools/sgf2gtp.pl index fbcf2cb..23561db 100755 --- a/tools/sgf2gtp.pl +++ b/tools/sgf2gtp.pl @@ -3,9 +3,18 @@ # format so that you can feed them to Pachi, insert genmove at # the right places etc. Might not work on obscure SGF files, # and of course there must be no variations. +# +# When called with a filename argument, it will create the output +# file with .gtp extension instead of .sgf. use warnings; +if ($ARGV[0]) { + open STDIN, "$ARGV[0]" or die "$ARGV[0]: $!"; + my $ofile = $ARGV[0]; $ofile =~ s/sgf$//i; $ofile .= 'gtp'; + open STDOUT, ">$ofile" or die "$ofile: $!"; +} + local $/ = undef; my $sgf = <>; my $size = ($sgf =~ /SZ\[(\d+)\]/)[0]; $sgf =~ s/\bC\[.*?\]//gs; # no comments -- 2.11.4.GIT