So, you would advocate for not using any switches on the perl shebang, right?
Putting
binmode STDOUT, ':utf8'; in cgiapp_prerun and doing
binmode STDOUT,':raw'; just on runmodes where I output binary data is a very elegant solution, I think, as it resets STDOUT to :utf8 on every new cycle. -Right?
In regards to "automatic
decode_utf8($v) on form input with detection of uploads" I am conservative. Had a bit of trouble with it, thus falling back to doing it on a per runmode basis. Are your experiences more consistent (would this be production code)?
I can't share your last comment: Might be that I do things less efficient but I have my fastcgi loop far enough around everything, so I can use the normal runmode switching facility and all mentioned plugins work under CGI::Fast.
My (updated without -COE switches) current app.fcgi:
#!/usr/bin/perl
use CGI::Fast();
use App;
use utf8;
# fastcgi usage as told in: http://cgiapp.erlbaum.net/index.cgi?FastCG
+I
while( my $q = new CGI::Fast ){
$q->header(-charset => 'utf-8'); # as I now set :utf8 in cgiap
+p_prerun, might be more beautiful to also move this there..
my $app = new App( QUERY => $q );
$app->run();
}
and in App.pm:
use base 'CGI::Application';
...
sub cgiapp_init {
## under FCGI CGI::Application permanently re-inits itself. No
+t what you would expect from cgiapp_init and setup, anyway...
## so we do a hack to get this here executed only once. setup(
+) can be executet over and over
if(!$self->{remember_app_init_done}){
# do one time setup stuff here
}
## declare init done
$self->{remember_app_init_done}=1;
}
sub setup {
...
## prepare runmodes
$self->start_mode('default');
# $self->error_mode('error');
$self->run_modes();
...
}
...
Actually, the above code isn't exactly my code, as I think I found a bug in the logic while writing this (I've already corrected the above based on this).
What I haven't changed in the above is, now that I think about it, the setup() stuff should also run just once, shouldn't it...?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.