please dont rip this site

Perl HTTP Services

Perl CGI

Decoding HTML requests:

	($command, $request, $method) = split(" ",$command);
	($document, $request) = split("\\\?",$request);
	for (split("&",$request) ) {
		s/\+/ /g;
		($key, $val) = split("=",$_); 
		$key =~ s/%(..)/pack("c",hex($1))/ge;
		$val =~ s/%(..)/pack("c",hex($1))/ge;
		$query{$key} = $val;
sub escapeHTML {
         my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_);
         return undef unless defined($toencode);
         return $toencode if ref($self) && $self->{'dontescape'};
         $toencode =~ s{&}{&}gso;
         $toencode =~ s{<}{&lt;}gso;
         $toencode =~ s{>}{&gt;}gso;
         $toencode =~ s{"}{&quot;}gso;
         my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' ||
                     uc $self->{'.charset'} eq 'WINDOWS-1252';
         if ($latin) {  # bug in some browsers
                $toencode =~ s{'}{&#39;}gso;
                $toencode =~ s{\x8b}{&#139;}gso;
                $toencode =~ s{\x9b}{&#155;}gso;
                if (defined $newlinestoo && $newlinestoo) {
                     $toencode =~ s{\012}{&#10;}gso;
                     $toencode =~ s{\015}{&#13;}gso;
         return $toencode;

sub unescapeHTML {
    my ($self,$string) = CGI::self_or_default(@_);
    return undef unless defined($string);
    my $latin = defined $self->{'.charset'} ? $self->{'.charset'} =~ /^(ISO-8859-1|WINDOWS-1252)$/i
                                            : 1;
    # thanks to Randal Schwartz for the correct solution to this one
    $string=~ s[&(.*?);]{
	local $_ = $1;
	/^amp$/i	? "&" :
	/^quot$/i	? '"' :
        /^gt$/i		? ">" :
	/^lt$/i		? "<" :
	/^#(\d+)$/ && $latin	     ? chr($1) :
	/^#x([0-9a-f]+)$/i && $latin ? chr(hex($1)) :
    return $string;

Encodeing CGI Environment Variables for handoff to a CGI program

$ENV{SERVER_NAME} = Sys::Hostname::hostname();
$ENV{SERVER_PROTOCOL} = $protocol;
$ENV{QUERY_STRING} = $querydata;
$ENV{REMOTE_ADDR} = $client->peerhost;
$ENV{HTTP_ACCEPT} = $request{'Accept'};
$ENV{HTTP_USER_AGENT} = $request{'User_Agent'};
$ENV{SCRIPT_NAME} = $request->url->epath;

See also

See also:

file: /Techref/language/perl/www.htm, 3KB, , updated: 2001/6/21 13:55, local time: 2020/10/29 18:18,

 ©2020 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> Perl HTTP Services</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!