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;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.