I know this type of question has been asked many times, but none of the answers are working for me. Here is what I want to do:
1) read a file in UTF-8 encoding
2) do a bunch of processing - character by character, concatenations, substrings, concatenating it with other variables and other constants
3) write the resulting record out in UTF-8
I have tried using "< :encoding(UTF-8)" on the open. It reads it won't read a single line - there is no error message - the program hangs and aborts.
I have tried reading a record without encoding and then doing a decode("UTF-8",$_) (note I have put $_ into a variable, and I do chomp it). This works, but reads the file and processes the record just as if it was ASCII.
As I understand it, PERL has its own internal encoding. All the variables are in that encoding. If I don't specify a thing I assume the reads and writes default to the machine's encoding which is ASCII (Windows is what I want it to run on). So I think all I have to do is read the input file using encoding, do my work, then encode the result and write the resulting record. It isn't working at all.
I did add the "use" as well.
And note - I am doing the read with the diamond operator in a while... while (<INFILE>)
Any sample program or advice would be much appreciated. I cannot even find a sample program on the internet yet that reads a file and writes some output.