in reply to efficientcy

You don't need to import any symbols (the qw(...) stuff on the 'use CGI' line) if you are using the OO interface (calling CGI methods instead of functions). You imply there might be more than two sections, so I might do it this way (slightly more inefficient maybe but I think neater than a big if..elsif..else section):
#!/usr/bin/perl use CGI; use strict; my $query = new CGI; print $query->header; my %func_map = ( home=>\&home, news=>\&news, ); my $default = "home"; my $location = $query->param("place") || $default; $location = $default unless exists $func_map{$location}; $func_map{$location}->(); sub home{ print "this is home"; } sub news{ print "this is news"; }

Replies are listed 'Best First'.
Re: Re: efficiency
by john1987 (Acolyte) on Jan 26, 2001 at 06:14 UTC
    slightly inefficient but yet a work of art as all perl scripts are. thanx for the help. later. -john