Dear and Serene Monks

I would like to know if there's a possibilty of confusion between the two "$_" in my program (each $_ correponds to a line of a input file (there are two input files for my code)

My code seems to work but I would like be 100 % sure it's OK

Here is my code

#!/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;


Here is my first input file : the analysis file (the true one, the one I opened with wordpad)
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

Here is my second input file : the ALL_FT file
LIRF;KJFK;EEZ95A; EGKK;KATL;DAL11; ENCN;EHAM;KLM1210; LEMD;LIMC;AZA067;

Here is my output file
DAL11 EEZ95A

In reply to risk of confusion by steph_bow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.