08:48:45;"";"";;""; 08:49:43;"DAL11";"08:47";527;"08:50";530 08:50:41;"";"";;""; 08:51:40;"";"";;""; 08:52:38;"";"";;""; 08:53:36;"ACA879";"08:51";531;"08:53";533 08:54:35;"";"";;""; 08:55:33;"SHT8K";"08:48";528;"08:55";535 08:56:31;"";"";;""; 08:57:30;"DLH9FM";"08:53";533;"08:57";537
#!/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 (<INFILE>){ 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_m +in;$flight_big_delay\n"; } else{ print OUTFILE "$aircraft_id;$ATO_min;$CTO_min;$delay_ATO_CTO_m +in\n"; } } close INFILE; close OUTFILE;
"";;; "DAL11";527;530;3 "";;; "";;; "";;; "ACA879";531;533;2 "";;; "SHT8K";528;535;7 "";;; "DLH9FM";533;537;4
update : the update concerns both the input and output since the original post data copied from wordpad, not from excel, for the input data as well as the output dataArgument "" isn't numeric in numeric gt(>) at Monks_Treatment.pl (that +'s the name of the program) line 60, <INFILE>
In reply to warnings unexpecetd by steph_bow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |