FireBird34 has asked for the wisdom of the Perl Monks concerning the following question:
I'm messing around with trying to link to different sections in a script, so that I can click on a link (ie. script.cgi?abc, and &abc; will run). It works, but with some *issues*.
Any help would be appreciated.
If you comment out 'use strict;', this will work with no problems... but with strict on, it won't allow me to use the call &$sub;. Is there an easy way to get around that problem? Also, is there an easier way of doing what I'm trying to do here? (in that above code, I know that I can take off if($q->param) { }, however I'll be needing it later, so I just left it =P#!perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); #errors will show in browser my $q = new CGI; print qq! <a href="script.cgi?one">one</a> <br> <a href="script.cgi?two">two</a> <br> <a href="script.cgi?three">three</a> !; if($q->param){ my $sub = $ENV{'QUERY_STRING'}; if(defined &$sub){ print "<BR><BR>"; &$sub; }else{ print "<BR><BR>"; &error; } } sub one { print "sub... one"; } sub two { print "sub... two"; } sub three { print "sub... three"; } sub error { print "ERROR\!\!"; }
Any help would be appreciated.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: URL linking within script
by jgallagher (Pilgrim) on May 13, 2003 at 05:12 UTC | |
by FireBird34 (Pilgrim) on May 13, 2003 at 05:18 UTC | |
Re: URL linking within script
by december (Pilgrim) on May 13, 2003 at 12:12 UTC | |
Re: URL linking within script
by pzbagel (Chaplain) on May 13, 2003 at 05:02 UTC | |
by chromatic (Archbishop) on May 13, 2003 at 05:10 UTC |
Back to
Seekers of Perl Wisdom