I'm using Perl to create a very long CSV file based off conditions determined from an input file. The input file has lines that consist of variables that are comma-separated, which I've "split" and defined as $a,$b,$c. The output file is similar to the input file, except for $c, which is determined by certain conditions in the input file (let's say $c changes to $z in the new file). I'm currently using "open (NEWFILE, ">C:/...");", then "print NEWFILE "$a,$b,$z\n"" (actually much more complicated than this, but you get the idea...) to write the new file. It seems silly to create an entire new file when I could just be editing the $c variable in the input file... am I right?
I'm using Tie::File to read the input file line-by-line as an array. I understand that I can also use this method to modify records in a file, which would cut out the seemingly wasteful step of making a new file... however, I'm not sure how to modify just one variable of a split line using this method (e.g. change $c to $z in each line). This is probably simple, but I can't seem to get the right syntax to make this happen. Can anyone lead me in the right direction? Let me know if you need more info about the script.