in reply to generate new files
I'm sorry, but can't tell what the error is from this code. (Try reading the other replies, maybe I failed to notice an obvious errors.)
My guess is that you might not be opening the right input CSV file; or that you are opening more than one input files but write the result to the same output file and the last input file is empty or unreadable or is a directory; or that writing to the output file fails because the disk or quota is full (this has happened to me). Note that as you are opening the output with > mode, you overwrite it with every open.
You might try adding debugging statements to see what the code does, for example something like this might help. If you see that the same output file is reported multiple times or that the input file is empty, you'll be able to know where to search further.
if ($rim1_thecode ne "") { ##generate RIM1 csv file## open (CSVIN, "<$CSV_file") or die "Can't open $CSV_file: $!\n"; $outcsv_file = $rim1_thecode."\.csv"; open (CSVOUT, ">$outcsv_file") or die "Can't open $outcsv_file: $!\ +n"; warn "transforming $CSV_file -> $outcsv_file"; @lines=<CSVIN>; warn "read ", 0 + @lines, " lines"; for $line(@lines) { ##substitute $thecode with RIM1 transaction code## $line =~ s/$thecode/$rim1_thecode/; print CSVOUT $line; } close CSVIN; close CSVOUT; }
|
|---|