Hi,

I have just written a module that takes the QUERY_STRING var and splits it up into a hash. The only prob ive got is stricngs are not being html-decoded. Heres the script/mod i use:

#! 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__

Anyone know whats going on? and by the way the MAIN is present when i try it.

Elfyn


In reply to HTML Decoding by emcb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.