mirror of
https://gitlab.com/klmp200/LO41.git
synced 2024-11-14 21:03:23 +00:00
44 lines
1.1 KiB
Perl
44 lines
1.1 KiB
Perl
|
use strict;
|
||
|
use warnings;
|
||
|
use List::Util qw/shuffle/;
|
||
|
|
||
|
my $visitors_db_filename = "visitors.db";
|
||
|
my $residents_db_filename = "residents.db";
|
||
|
my @visitors = ();
|
||
|
my @residents = ();
|
||
|
my $total_nb = $ARGV[0];
|
||
|
my $visitors_nb = $ARGV[0]; #todo : calculer
|
||
|
my $residents_nb = $ARGV[1];
|
||
|
my $output_file_name = $ARGV[2] eq "" ? "out" : $ARGV[2];
|
||
|
|
||
|
open(my $visitors_db_file, $visitors_db_filename) or die "Error : no visitors database found \n";
|
||
|
|
||
|
open(my $residents_db_file, $residents_db_filename) or die "Error : no residents database found \n";
|
||
|
|
||
|
while(my $line = <$visitors_db_file>){
|
||
|
#chomp($line);
|
||
|
push(@visitors, $line);
|
||
|
}
|
||
|
while(my $line = <$residents_db_file>){
|
||
|
#chomp($line);
|
||
|
push(@residents, $line);
|
||
|
}
|
||
|
|
||
|
die "Database is not big enough for $visitors_nb visitors\n" if @visitors < $visitors_nb;
|
||
|
die "Database is not big enough for $residents_nb residents" if @residents < $residents_nb;
|
||
|
|
||
|
@visitors = shuffle(@visitors);
|
||
|
@residents = shuffle(@residents);
|
||
|
|
||
|
open(my $output_file, '>'.$output_file_name) or die "Error : couldn't create output file.";
|
||
|
|
||
|
for(my $i = 0; $i < )
|
||
|
foreach (@visitors){
|
||
|
print;
|
||
|
}
|
||
|
|
||
|
close $visitors_db_file;
|
||
|
close $residents_db_file;
|
||
|
|
||
|
|