steph_bow has asked for the wisdom of the Perl Monks concerning the following question:
#!/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 ope +n 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 (<INFILE>){ # the /^ indicates the begining of the research for $_ ($_ is unde +rstated 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_f +ile} : $!"; ############################################################## +############# while(<INFILE_2>){ 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 e +st $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 OUTFI +LE print OUTFILE "$aircraft_id\n"; } } close INFILE_2; } } close INFILE; close OUTFILE;
08:47:46;;;;; 08:48:45;;;;; 08:49:43;DAL11;08:47;527;08:50;530;3 08:50:41;;;;; 08:51:40;;;;; 12:16:28;RYR211;12:13;733;12:16;736;3 12:17:26;EEZ95A;12:23;743;12:17;737;-6 12:18:24;SHT2938;12:24;744;12:17;737;-7
LIRF;KJFK;EEZ95A; EGKK;KATL;DAL11; ENCN;EHAM;KLM1210; LEMD;LIMC;AZA067;
DAL11 EEZ95A
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: risk of confusion
by shmem (Chancellor) on Aug 07, 2007 at 16:07 UTC | |
by jdporter (Paladin) on Aug 07, 2007 at 18:56 UTC | |
by shmem (Chancellor) on Aug 07, 2007 at 21:53 UTC | |
|
Re: risk of confusion
by thezip (Vicar) on Aug 07, 2007 at 16:04 UTC |