#! F:\perl\bin\perl use HTTP::QueryString; print "Content-Type: text/html\n\n"; $qs = new HTTP::QueryString; $qs->parse; $keys = HTTP::QueryString::param; print $keys->{'MAIN'}, '\n'; #### # Application name: N/A # Package name: QueryString package HTTP::QueryString; # load the needed modules for this application or module: # # Here is where you will need to load all of the modules used # by this app/mod. Anything may 'use'd will not be imported # and thus not used. use vars qw( $VERSION %GLOENV %PRIENV ); # Set up the needed OO interface refs: # # Any object-orientated programming within this app/mod will # need an object identifier. Otherwise again will not be # available for this app/mod. use URI::Escape; # Setting the version number of your app/mod: # # This is your global variabe VERSION. which is used to identify # well the version of your app/mod. $VERSION = '0.1a'; # Methods: # # Whether this is an application or perl module you'll need some # methods. And here's where they go. sub new { my $pkg = shift; %HTTP::QueryString::PRIENV = @_; my $obj = \%HTTP::QueryString::GLOENV; bless $obj, $pkg; return $obj; } sub parse { my $qs = $ENV{'QUERY_STRING'}; my @qs2 = split(/&/, $qs); for( my $i=0; $i<=$#qs2; $i++ ) { my($var,$val) = split(/=/, $qs2[$i]); $HTTP::QueryString::GLOENV{$var} = $val; } foreach $var (sort(keys(%CONFIG))) { $val = $CONFIG{$var}; $val =~ s|\n|\\n|g; $val =~ s|"|\\"|g; $val = uri_unescape($val); } return 1; } sub param { return \%HTTP::QueryString::GLOENV; } # Returning true: # # If this is a perl module then you will need to uncomment the # next line 1; __END__