Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: using hash to lookup value

by naikonta (Curate)
on Oct 16, 2007 at 02:54 UTC ( #645100=note: print w/replies, xml ) Need Help??

in reply to using hash to lookup value

Rolling your own CGI parameter parsing is not recommended but nothing stops from you doing that. Well, if you insist....
my %params; # declare a hash to hold the params later if ($ENV{REQUEST_METHOD} eq 'GET' && $ENV{QUERY_STRING} ne '') { .... foreach .... { my($name, $value) = split .... # get the name and value ..... # cleaning name and value $params{$name} = $value; # hash assignment } }
But, if you don't mind to use a CPAN module (I do recommend it), you can use or CGI::Simple. I assumed that the topic is requested with topic parameter (such as and that each topic has a corresponding html file.
#!/usr/bin/perl use strict; use warnings; use CGI::Simple; my $baseurl = ''; my %available_topics = ( home => 'home.html', user => 'user.html', add => 'add.html', update => 'update.html', remove => 'remove.html', #... other help topics ); my $default_topic = 'home'; my $cgi = CGI::Simple->new; # let CGI::Simple does the parsing my $topic = $cgi->param('topic') || ''; # get the wanted topic # get corresponding html file my $help_file = $available_topcs{$topic} || $available_topics{$default +_topic}; # send redirection print $cgi->redirect("$baseurl/$help_file");

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Replies are listed 'Best First'.
Re^2: using hash to lookup value
by grashoper (Monk) on Oct 16, 2007 at 03:52 UTC
    Thanks for the quick response, we are using activestate perl and pages are being output via xml in different locations in this webapp that is the site..xmlwriter outputs some of it, it uses xslt transforms but I am not well versed in that either so not sure how to pass a query string in one of those (I know its supposed to be possible but I don't understand it well enough to want to attempt it) data stored in sql for each site etc, the helpfiles themselves are populated into an iframe they are just html, could this be done without using cgi? This section I am working on goes from our webapplication to our help website its passing authentication from the webapp as well as where in our application they are,my goal is to make the help "context" sensitive based on what is returned in that string and make it appear on the page. your assumptions are correct in regards to the topic. time is an issue here as well, they want this working right away, which of course doesn't help my learning curve much .. many thanks for the sample, I will work on today and write back if I am still stupid tomorrow..I probly will

      Or if you don't like (why?):

      print "Location: "$baseurl/$help_file\n\n";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://645100]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2019-07-18 10:57 GMT
Find Nodes?
    Voting Booth?

    No recent polls found