I am looping through files in a directory and printing to csv files with:
The problem is it only writes out with the first file it comes to. I originally had the program writing out to the csv files line by line inside the code and everything worked fine, then I made some necessary code changes to incorporate the %parents hash and now it still creates the other csv files but they are all 0 bytes. No matter what combination of files there are in the directory it only writes data to the first one. Any ideas?
Thanks in advance.
Code:
.
.
opendir D, $opts{d} or die ...;
.
.
foreach my $file (readdir D)
{
my ($filebase, $dirname, $ext) = fileparse($file, '\..*');
my $csvFile = "$opts{d}\\$filebase.csv";
open FILE_OUT, ">$csvFile" or die ...;
.
.
foreach my $parent (@parents)
{
print FILE_OUT $parents{$parent} . "\n";
}
close FILE_OUT;
}
The problem is it only writes out with the first file it comes to. I originally had the program writing out to the csv files line by line inside the code and everything worked fine, then I made some necessary code changes to incorporate the %parents hash and now it still creates the other csv files but they are all 0 bytes. No matter what combination of files there are in the directory it only writes data to the first one. Any ideas?
Thanks in advance.