#!/usr/bin/perl use strict; use warnings; use diagnostics; ################# IN WHICH DIRECTORY WE ARE ######################## my $Current_Dir = `pwd`; print STDOUT "the current directory is $Current_Dir"; ##################################################################### ################### OPEN THE FIRST INFILE ############################ # open the first file # do not forget the "" to declare my ${first_file} = my ${first_file} = "$ARGV[0]"; open(INFILE,"<${first_file}") or die "Can't open ${first_file} : $!"; ################################################################# ################### OPEN THE OUTFILE ############################ # name of the OUTFILE # never put a \n at the end of the OUTFILE name otherwise it does not create the output my ${outfile_name} = "Analysis_${first_file}"; # to open the file # OUTFILE is the name of the HANDLE in this case open (OUTFILE, ">${outfile_name}") or die "Can't open ${outfile_name}: $!"; ################################################################## while (){ chomp($_); my @Parts = split(";"); my $aircraft_id = $Parts[1]; my $ATO_min = $Parts[3]; my $CTO_min = $Parts[5]; my $ATO = $Parts[2]; my $CTO = $Parts[4]; my $delay_ATO_CTO_min; if (($CTO =~ /(\d\d):(\d\d)/) & ($ATO =~ /(\d\d):(\d\d)/)){ $delay_ATO_CTO_min = $CTO_min-$ATO_min; } else{ $delay_ATO_CTO_min = ""; } my $flight_big_delay; # condition on the delay if ($delay_ATO_CTO_min > 10){ $flight_big_delay = $aircraft_id; print OUTFILE "$aircraft_id;$ATO_min;$CTO_min;$delay_ATO_CTO_min;$flight_big_delay\n"; } else{ print OUTFILE "$aircraft_id;$ATO_min;$CTO_min;$delay_ATO_CTO_min\n"; } } close INFILE; close OUTFILE;