$menu = $ENV{'QUERY_STRING'};
if ($menu eq "about") {&displayAbout;}
elsif ($menu eq "links") {&displayLinks;}
else {&displayHome;}
sub displayHome {
$h = $ENV{'QUERY_STRING'};
if ($h eq "de") {&de;}
elsif ($h eq "fr") {&fr;}
else {&en; print $home;}
print "<a href=$ENV{'SCRIPT_NAME'}>en</a>¦
<a href=$ENV{'SCRIPT_NAME'}?de>de</a>¦
<a href=$ENV{'SCRIPT_NAME'}?fr>fr</a>";
}
@pairs = split("\&",$ENV{'QUERY_STRING'});
foreach $command (@pairs) {
($parameterName,$value) = split("=",$command);
if ($parameterName eq 'menu') { $menu = $value; }
}
The way you have your querystrings could work:
<a href=index.cgi?links>
you don't have to have a name/value pair, a single word can work. But your links would be better if they were written as name/value pairs:
<a href=index.cgi?name=value&name=value>
this way you can send multiple commands to your script and use the CGI module to process the commands, or send only one name/value pair it that's what you want to do. Say your links look like this:
<a href=index.cgi?com=about&lan=de>
<a href=index.cgi?com=links&lan=fr>
use strict;
use CGI qw/:standard/;my $menu = param('com');
my $lan = param('lan');if ($menu eq 'about') {&displayAbout;}
elsif ($menu eq 'links') {&displayLinks;}
else {&displayHome;}sub displayHome {
if ($lan eq 'de') {&de;}
elsif ($lan eq 'fr') {&fr;}
else {&en; print $home;}
}
Read the CGI documentation for more indepth explanations:
[perldoc.perl.org...]