#open CSV for input open my $CSVIN, '<', $file; foreach (<$CSVIN>){ #split CSV into usable format #the real script has about ten variables (my $input1, $input2, $input3, $file_out) = split(/,/,$_); open my $TEMPLATEIN, '<', $path_to_template; open my $FHOUT, '>', $file_out; foreach (<$TEMPLATEIN>){ #search and replace in the template # where $search_pattern = arbitrary identifier #in the template, I've been using: #<<>> #again I have about twelve $_ =~ s/$search_pattern1/$input1/g; $_ =~ s/$search_pattern2/$input2/g; $_ =~ s/$search_pattern3/$input3/g; print $FHOUT $_; } # end s/r from template close($FHOUT); close($TEMPLATEIN) } # end iteration through CSV