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; }

In reply to Re: generate new files by ambrus
in thread generate new files by tkn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.