http://www.perlmonks.org?node_id=645100


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 CGI.pm or CGI::Simple. I assumed that the topic is requested with topic parameter (such as http://www.example.com/cgi-bin/help.cgi?topic=user) and that each topic has a corresponding html file.
#!/usr/bin/perl use strict; use warnings; use CGI::Simple; my $baseurl = 'http://www.example.com/helps'; 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!