in reply to CGI.pm: "Malformed UTF-8 character" in apache's error.log

From your input (not yet woven in ikegami's last post, working on it) I constructed this variation, which should replicate in a simplified form, what the routine in my more complex CGI::Application script will be like:
#!/usr/bin/perl -COE use CGI; use CGI::Carp qw(fatalsToBrowser); use utf8; use Encode; my $cgi = new CGI; my $formtext = decode("utf8", $cgi->param("formtext") ); # this may be + abc or contain chinese my $filename = $cgi->param('file'); my $fh_in = $cgi->upload('file'); open(my $fh_out, '>', "/var/www/clipland/www.clipland.com/$filename") +or die $!; binmode $fh_in; binmode $fh_out; local $/ = \4096; # Don't wait to find "\n" while (<$fh_in>) { print $fh_out $_; } $cgi->header(-charset => 'utf-8'); print $cgi->header(); print "$filename has been successfully uploaded... Now some umlauts: ä +öü";

1. It only uses the -COE switch for Stdoutput and Stderr. (using -CS will give the error, despite ikegami's fixes) and as Juerd pointed out: it's safer.
2. I do not switch utf8 on for the Stdinput, thus I need to manually decode form data from text fields - right?

Is this OK? Anything I've overseen?

BTW: no kidding? I have to differentiate between text and binary data?? A great relief to hear that utf8 text files are also binary data... ;-)