#!/usr/local/bin/perl # $Id: irex-output-merge.perl,v 3.0 1998/11/19 07:12:08 tsuchiya Exp $ # This file is part of IREX tools. # Please refer "Copyright file" at the root directory. # (C) IREX committee IREX実行委員会. All rights reserved. require 5.000; use lib ( "$ENV{IREX_ROOT}/IR_TOOLS/perl", "$ENV{IREX_ROOT}/perl" ); use IREX::Kekka qw( :parser ); use IREX::Tougou qw( :generator ); use File::Basename; $PROGRAM = basename( $0 ); $SUFFIX = 'irj'; #------------------------------------------------------------ # コマンドラインオプションの解析 #------------------------------------------------------------ while( $_=shift(@ARGV) ){ if( /^-(h|\?|-help)$/ ){ &print_usage; } elsif( /^-(f|-prefix)$/ ){ $BASENAME = shift @ARGV; } elsif( /^-(n|-debug)$/ ){ $DEBUG = 1; } elsif( /^-(q|-quiet)$/ ){ $SILENT = 1; } else { push( @FILE,$_ ); } } unless( @FILE ){ push( @FILE,"STDIN" ); $STDIN = 1; } &print_usage if ( $DEBUG==0 )&( ! defined($BASENAME) ); #------------------------------------------------------------ # 本体 #------------------------------------------------------------ for $f ( @FILE ){ if( $STDIN ){ @BUF = ; } else { open( FILE,"< $f" )||die "Can't open file to read: $f\n"; print STDERR "Reading $f ...\n" unless $SILENT; @BUF =; close FILE; } print STDERR "Parsing $f ...\n" unless $SILENT; &parse()||die "Parse error occured: $f\n"; } #------------------------------------------------------------ # データを整列して出力 #------------------------------------------------------------ for $topic_id ( &topic_id_list() ){ my $file; unless( $DEBUG ){ $file = sprintf( "%s_%04d.%s",$BASENAME,$topic_id,$SUFFIX ); if( -f $file ){ print STDERR "File is already exists: $file\nSkip.\n"; next; } else { open( FILE,"> $file" )|| die "Can't open file to write: $file\n"; select FILE; print STDERR "Writing $file ...\n" unless $SILENT; } } else { print STDERR "Printing data whose topic id is $topic_id ...\n" unless $SILENT; } &generate( $topic_id ); if( $file ){ close FILE; select STDOUT; } } #------------------------------------------------------------ # 簡易ヘルプ #------------------------------------------------------------ sub print_usage { die <<"__END_OF_USAGE__"; Usage: $PROGRAM -f prefix teisyutsu_1 teisyutsu_2 ... teisyutsu_n 複数の IREX 結果提出ファイル teisyutu_1 teisyutu_2 ... teisyutu_n をマージして、IREX 結果統合ファイルに変換する。変換結果は、 TOPIC-ID によって異なるファイルに格納される。そのファイル名は -f によって指定され、次のような形式になる。 prefix_????.$SUFFIX ???? の部分には TOPIC-ID が入る。入力ファイルを指定しなかった場合 は、標準入力からデータを取り出す。 -q オプションを指定しなければ、処理の進行状況を標準エラー出力に出 力する。 __END_OF_USAGE__ }