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 () { 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;