Public Scratchpad | Download, Select Code To D/L |
extra CSS for dark theme. This is in a node somewhere
/* i don't browse full screen to have a small textarea :) */ textarea { width: 100%; height: 300px; } /* Code blocks in a nice white-bordered gray box */ pre tt { display: block; background-color: #404040; border: 1px solid white; width: 90%; padding: 0px 2ex 2ex 2ex; } /* I like a little feedback now and then */ a:hover { color: blue; }
tosh: Playing nice in mod_perl and CGI:
Figure out my environment:
Get request/form info in the same fashion for both environments:use constant HAS_MODPERL => eval { require Apache; }; unless ( HAS_MODPERL ) { require CGI; }
I form all my output and place it in a scalar, $out, then finish up with this:use vars qw($request %Args); $request = HAS_MODPERL ? Apache->request : new CGI; %Args = HAS_MODPERL ? $request->args : $request->Vars;
&output is the following:&output(\$out, $request) and exit;
sub output { my $out = shift; $out = ref $out ? $$out : $out; my $request = shift; if ( "$request" =~ /Apache/ ) { #test class $request->header_out("Content-Length" => length($out)); $request->content_type('text/html'); $request->send_http_header; } else { print $request->header(-type => 'text/html', -length => length($out) ); } print $out; }