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

How can i specify file encoding for a file opened in appending mode
open(DA,">:encoding(UTF-8)","$file") || print "Can't Open File. Try ch +mod 777 citydata directory<br><br>"; print DA $data; close(DA);
This will create file with utf 8 encoding but i want to open file in append mode thanks

Replies are listed 'Best First'.
Re: File in perl
by Anonymous Monk on Jul 01, 2011 at 06:56 UTC

    How can i specify file encoding for a file opened in appending mode

    That should be the title of your question.

    Each time you post a new node you get reminder to read How do I compose an effective node title? before you post -- you should go and read it now

    perldoc -f open |grep -i append

    If MODE is '>>', the file is opened for appending, again being

    # open for append, using the fileno of OLDFH

      Or even:

      >perldoc perlopentut | grep -in append 366: O_APPEND Append to the file 395: To open a file for appending, creating one if necessary: 398: sysopen(FH, $path, O_WRONLY | O_APPEND | O_CREAT); 414: To open a file for appending, where that file must already exi +st: 416: sysopen(FH, $path, O_WRONLY | O_APPEND); 523: starts with whitespace. Trailing whitespace is protected by ap +pending an