#!/usr/bin/perl use strict; use warnings; use diagnostics; # la commade "use strict" permet d'être plus rigoureux ############################################## # TASKS MADE BY THE SCRIPT ############################################## # the task of this script is to look for the following aircraft_id ################################## ## ARGUMENTS OF THE SCRIPT ################################## ##################################### # do not forget the $ before the ARGV ##################################### # THE FIRST ARGUMENT : # we have to give the name of the regulation which will help us to open the first file # the name of the first file to open is : Regulation_Slot_List_${reg_id} my ${reg_id} = "$ARGV[0]"; # THE SECOND ARGUMENT # it will be used later to open the ALL_FT file my $date = "$ARGV[1]"; ################# END OF THE DECLARATION OF THE ARGUMENTS ################# IN WHICH DIRECTORY WE ARE ######################## my $Current_Dir = `pwd`; print STDOUT "the current directory is $Current_Dir"; ##################################################################### ################### OPEN THE ANALYSIS INFILE ############################ # open the first file # do not forget the "" to declare my ${analysis_file} = my ${analysis_file} = "without_commas_Analysis_Regulation_Slot_List_${reg_id}_last.csv"; open(INFILE,"<${analysis_file}") or die "Can't open ${analysis_file} : $!"; ########################################################################### ################### OPEN THE OUTFILE ############################ # open the first file # do not forget the "" to declare my ${analysis_file} = my $outfile = "with_ALL_FT_${analysis_file}"; open(OUTFILE,">${outfile}") or die "Can't open ${outfile} : $!"; ########################################################################### # we want to skip the first line of the INFILE while (){ # the /^ indicates the begining of the research for $_ ($_ is understated here) my @Elements = split(/;/,$_); # $Elements[2] is the $CTO my $aircraft_id = $Elements[1]; if ($Elements[4] ne ""){ # print STDOUT "$Elements[4]"; ################### OPEN THE ALL_FT FILE ############################ # open the first file # do not forget the "" to declare my ${ALL_FT_file} = my ${ALL_FT_file} = "ALL_FT.${date}"; open(INFILE_2,"<${ALL_FT_file}") or die "Can't open ${ALL_FT_file} : $!"; ########################################################################### while(){ my $Line_ALL_FT = $_; print STDOUT "$Line_ALL_FT\n"; my @Parts_ALL_FT = split(/;/,$Line_ALL_FT); my $aircraft_ALL_FT_id = $Parts_ALL_FT[2]; # print STDOUT "le nom de l'avion dans le fichier ALL_FT est $aircraft_ALL_FT_id\n"; # print STDOUT "le nom de l'avion dans le fichier analysis est $aircraft_id\n"; next if ($aircraft_id ne $aircraft_ALL_FT_id); if ($aircraft_id eq $aircraft_ALL_FT_id){ # do not forget the "" in the declaration of the OUTFILE print OUTFILE "$aircraft_id\n"; } } close INFILE_2; } } close INFILE; close OUTFILE;