Thanks a lot Miller for your reply.
However, it does not seem to work
Here is my start file :
141
142
143 REGULATION SLOT LAYOUT + REGULATED FLIGHTS
144
I have tried to replace the text by the number (here 143) and it works
But it seems that the number at which step the text "REGULATION SLOT LAYOUT + REGULATED FLIGHTS" is likely to change.
Where did I go wrong ?
Here is my code
my $file = "$ARGV[0]";
################# END OF THE DECLARATION OF THE ARGUMENTS
my $Current_Dir = `pwd`;
# print STDOUT "the current directory is $Current_Dir";
# open the ALL_FT file
open(INFILE,"$ARGV[0]") or die "Can't open $ARGV[0]: $!";
# name of the OUTFILE
# do not forget the "" if
# never put a \n at the end of the OUTFILE name otherwise it does not
+create the output
my ${outfile_name} = "bon_format_$file";
# to open the file
# OUTFILE is the name of the HANDLE in this case
open (OUTFILE, ">${outfile_name}.csv") or die "Can't open ${outfile_
+name}.csv: $!";
my @Parts;
my $part;
while (<INFILE>) {
if (/^143/..eof(INFILE)){
# the lines are composed of elements separated by a point comma
my $Line = $_;
my @Elements = split(";", $Line);
my $element = $Elements[1];
@Parts = split(" ",$element);
foreach $part(@Parts){
print OUTFILE ";$part";
}
print OUTFILE "\n";
}
}
close INFILE;
close OUTFILE;
|