Perl Gurus, need some help with File Processing. I am trying to process a file where each line is treated as a record. The fileds in the record are separated by whitespaces. The number of white spaces between two fields can be >=1.
The idea is to read the input file, and copy it to an output file keeping the format of the records same (i.e same number of whitespaces betwwen two fileds). Here is the program that I have written, _____________________________________________ $FILE1 = <@ARGV>; print($FILE1); open(INFILE, $FILE1); @array = <INFILE>; close(INFILE); open(OUTFILE,">>xyz.dat"); foreach $line (@array) { @out = split(/ +/, $line); $count = @out; print($count); print("\n"); for ($i=0;$i<$count;$i++) {print OUTFILE (@out[$i]);} } ______________________________________________ Input File _________________________________________ 101 2.00 2.00 2.00 2.00 101 2.00 2.00 2.00 2.00 _________________________________________ However the output file generated is: _____________________________________________ 1012.002.002.002.00 1012.002.002.002.00 _____________________________________________ The spaces between the fields are missing. Please let me know how to get it working. Thanks, Gufran