#!/usr/local/bin/perl
#

$REP=$ARGV[0];
$FIL=$ARGV[1];
$PRC=$ARGV[2];

#$REP=$REP.$FIL.'/';


open(INFO,$REP.$FIL.'.dat');
@attr=<INFO>;
close(INFO);

$line=@attr[0];
chomp($line);
@mots = split(' ',$line);

$nb_ex=$mots[0];
$nb_at=$mots[1];

$nb_f1=int($nb_ex*$PRC/100);
$nb_f2=$nb_ex-$nb_f1;

print "nb_ex $nb_ex , perc $PRC , nb_f1 $nb_f1 , nb_f2 $nb_f2 \n";

open(F1,">$REP$FIL.learn");
print F1 "$nb_f1 $nb_at\n";
open(F2,">$REP$FIL.test");
print F2 "$nb_f2 $nb_at\n";

for($i=1;$i<=$nb_f1;++$i) {
  print F1 $attr[$i];
}
for($i=$nb_f1+1;$i<=$nb_ex;++$i) {
  print F2 $attr[$i];
}

close(F1);
close(F2);
