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