in reply to Replace Whitespace with Comma

You appear to be creating a CSV file. On the face of it your output line should be:

12345,"DOE,JOHN",$50.00,REFUND,COMPLETE

to preserve the sense of the input file where DOE,JOHN is a single field. You should seriously consider using Text::CSV to generate the output file. It will look after correct quoting and various other possible issues for you.

Premature optimization is the root of all job security