#!/usr/bin/perl
# Set up a CGI environment
$ENV{REQUEST_URI} = '/cgi-bin/foo.cgi/somewhere/else?game=chess@school&game=checkers&weather=dull';

$xx=$ENV{REQUEST_URI};
$encoded_xx=$xx;
$encoded_xx =~ s/([^a-zA-Z0-9_.%;&?\/\\:+=~-])/sprintf("%%%02X",ord($1))/eg;
$quotemetad_xx = quotemeta($xx);
   
print "\n-----------------------------------\n";
print '$xx ="' . $xx . '"' . "\n\n";
print '$encoded_xx=' . "\n     " . '"' . $encoded_xx . '"' . "\n\n";
print 'Quoted $encoded_xx=    (like patched CGI.pm in perl-5.8.0)' . 
      "\n     " . '"' . "\Q$encoded_xx\E" . '"' . "\n\n";
print 'quotemeta($xx)=        (like unpatched CGI.pm in perl-5.8.3)' . 
      "\n     " . '"' . $quotemetad_xx . '"' . "\n\n";
print 'Quoted quotemeta($xx)= (like patched CGI.pm in perl-5.8.3)' . 
      "\n     " . '"' . "\Q$quotemetad_xx\E" . '"' . "\n";
print "-----------------------------------\n\n";
 
# -----  END OF SOURCE
