soubalaji has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Iam having one text file with UTF mode. Iam using open_bom module to open this mode. But i want to save the text file in the same mode (i.e. in the UTF mode).

Any body help me in this how to save the text file in the same mode.

Regards, Balaji S

Replies are listed 'Best First'.
Re: How to save in UTF Mode
by moritz (Cardinal) on Apr 22, 2009 at 13:19 UTC
    To save a file as UTF-8, open the file handle with open my $handle, ">:encoding(UTF-8)", $filename or die ....

    This also works for other encodings.

    See also perluniintro, perlunicode and Encodings, Unicode and Perl.

    (Update: fixed reading/writing direction in the open mode, thanks to ikegami++).