I have a .csv file which contains only one line. Say the file name is new.csv and the line in that is > abc,add,aer,adfw,asdf
Now I'm trying to read this file and then trying to append another data to that by writing to that same file like this.
open(FH , '+<' , "") or die "Cannot open the file : $!"
while(<FH>){
chomp($_);
print FH ", new_data";
}
close(FH)
By running this
Expected output :
abc,add,aer,adfw,asdf, new_data
Actual output :
abc,add,aer,adfw,asdf new_data
That is the new data is getting added to a new line even though i used the chomp on $_.
The other things I've tried out is
I tried writing to a brand new file and then use the system() function to replace the new file with the old one.
I tried using join function and string concatenation function.
I tried sending the line to a new variable and then appending data and then writing to the file.
All of them have failed.
Thanks for you help.
Sai Pavan Yaraguti