- Read section about using sub main in tye's scratchpad (search page for "stupid")
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; }
Re: s/\w/random character/g
tosh: Playing nice in mod_perl and CGI:
Figure out my environment:
use constant HAS_MODPERL => eval { require Apache; };
unless ( HAS_MODPERL ) {
require CGI;
}
Get request/form info in the same fashion for both environments:
use vars qw($request %Args);
$request = HAS_MODPERL ? Apache->request : new CGI;
%Args = HAS_MODPERL ? $request->args : $request->Vars;
I form all my output and place it in a scalar, $out, then finish up with this:
&output(\$out, $request) and exit;
&output is the following:
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;
}
|