A
Ameya
Hello,
I have a directory with about 4000 CSV files (19MB each). I list the
files in another TXT file and then read each line and store it a $file
variable. I open $file which is a CSV file (19MB) and want to print a
variable in a file. However, that does not seem to be possible
although as a check I print the value on the screen successfully. As
an additional check I also try to print "hello" in the output file but
nothing gets printed. On the other hand if I print hello before
reading the CSV file then it does it successfully.
What could be the problem and how can I get my values to print in the
file. Following is the code snippet explaining the read and write
commands I use in my code.
********************************************
open my $fin, '<', $inFile or die "could not open file '$inFile' $!";
# Open the file for reading, $inFile is a CSV file
while (my $line = <$fh>) {
chomp($line);
...........
.........
$a = $line;
}
print $fout "$a\n" or die "Can't print in the file $outFile: $!"; #
There is no value of $a in $outFile
print $fout "Hello\n" or die "Can't print in the file $outFile: $!"; #
There is no "Hello" statement in $outFile
print "Hello\n" or die "Can't print in the file $outFile: $!"; #Prints
Hello on the screen
************************************************
Thanks and Regards,
Ameya
I have a directory with about 4000 CSV files (19MB each). I list the
files in another TXT file and then read each line and store it a $file
variable. I open $file which is a CSV file (19MB) and want to print a
variable in a file. However, that does not seem to be possible
although as a check I print the value on the screen successfully. As
an additional check I also try to print "hello" in the output file but
nothing gets printed. On the other hand if I print hello before
reading the CSV file then it does it successfully.
What could be the problem and how can I get my values to print in the
file. Following is the code snippet explaining the read and write
commands I use in my code.
********************************************
open my $fin, '<', $inFile or die "could not open file '$inFile' $!";
# Open the file for reading, $inFile is a CSV file
while (my $line = <$fh>) {
chomp($line);
...........
.........
$a = $line;
}
print $fout "$a\n" or die "Can't print in the file $outFile: $!"; #
There is no value of $a in $outFile
print $fout "Hello\n" or die "Can't print in the file $outFile: $!"; #
There is no "Hello" statement in $outFile
print "Hello\n" or die "Can't print in the file $outFile: $!"; #Prints
Hello on the screen
************************************************
Thanks and Regards,
Ameya