Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: efficiency

by runrig (Abbot)
on Jan 25, 2001 at 23:57 UTC ( [id://54451]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 01:14 UTC
    slightly inefficient but yet a work of art as all perl scripts are. thanx for the help. later. -john

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://54451]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.