Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

hattmoward's scratchpad

by meredith (Friar)
on Jun 04, 2004 at 04:52 UTC ( #360693=scratchpad: print w/replies, xml ) Need Help??

  • 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; }

Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2017-07-28 08:04 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (424 votes). Check out past polls.