#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use open qw/:std :utf8/;

use Encode;
use Getopt::Long;

my ($programme) = $0 =~ m|^(?:.*/)?(.+)|;
$programme = decode_utf8($programme);

my $wos   = ""; #par exemple "Vieil_v2_wos.txt"
my $info  = ""; #par exemple "J9UT.txt"

eval	{
	$SIG{__WARN__} = sub {usage(1);};
		GetOptions(
		"wos=s"      => \$wos,
		"info=s"  => \$info,
		);
	};
$SIG{__WARN__} = sub {warn $_[0];};

usage(2) if not $wos or not $info;

open(WOS,  "<:encoding(UTF-8)", $wos) or 
	die "Couldn't open file $wos, $!";
open(INFO, ">:encoding(UTF-8)", $info) or 
	die "Couldn't open file $info, $!";

while (my $ligne = <WOS>)
{
	chomp($ligne);
	if ($ligne =~ /^J9 /)
		{
		print INFO "$ligne;";
		}
	if ($ligne =~ /^UT ISTEX:/)
		{
		print INFO "$ligne\n";
		}
}
close WOS;
close INFO;

exit 0;

sub usage
{
my $code = shift;

print STDERR "Usage : $programme -w wos -i info \n";

exit $code;
}






