I need to read several files and create a new file with 3 values; the original file name, the company (field[6]) , and the PO number (field[10]).
I tried;
$vName1="out.txt";
@files= < $LAWDIR$sys/fax/POfax/* >;
foreach $file (@files)
{
open(IN, "$file") or die 'Could not open file1 for reading';
open(OUT, ">>$vPath2$vName1") or die 'Could not open file2 for writing';
foreach $line (<IN>)
{
chomp;
$field = split(/\,/, $line);
$vLn = $file . "," . $field[6] . "," . $field[10] . "\n";
print OUT $vLn;
}
}
This creates a output line for every line of the input file, and the values for field[6] and field[10] are always blank.
I only want to read the second line of each file.
Can somebody help me?
I tried;
$vName1="out.txt";
@files= < $LAWDIR$sys/fax/POfax/* >;
foreach $file (@files)
{
open(IN, "$file") or die 'Could not open file1 for reading';
open(OUT, ">>$vPath2$vName1") or die 'Could not open file2 for writing';
foreach $line (<IN>)
{
chomp;
$field = split(/\,/, $line);
$vLn = $file . "," . $field[6] . "," . $field[10] . "\n";
print OUT $vLn;
}
}
This creates a output line for every line of the input file, and the values for field[6] and field[10] are always blank.
I only want to read the second line of each file.
Can somebody help me?