Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found