in reply to efficientcy
#!/usr/bin/perl -w use CGI qw(:standard); use strict; #always! my $location = param("place"); print header; my %subs = ( 'home'=>\&home, # Just add a key and then a value then put your 'news'=>\&news, # stuff in a subroutine :) Yay! ); if (!$location){ &home }elsif (defined(my $action = $subs{$location})){# Thanks Chromatic $action->(); } # Q&A -> Subroutines -> How to make subroutine accessible as foo.pl?fo +o # Thanks again :-) ############### # Subroutines # ############### sub home{ print "this is home. I am John, hear me roar"; } sub news{ print "this is news"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: efficiency (Spelled it wrong :-)
by Yohimbe (Pilgrim) on Jan 26, 2001 at 22:24 UTC |