--- Wiggins d'Anconia <[EMAIL PROTECTED]> wrote: > > > Denzil Kruse wrote: > > Hi, > > > > I have a script for a cgi form that covers about > 20 > > pages, and want to name a subroutine to handle > each > > page like this: page1, page2, page3, etc. > > > > Once the script figures out which page it should > go > > to, I dont want to have to do this: > > > > if ($page == 1) { &page1() } > > if ($page == 2) { &page2() } > > if ($page == 3) { &page3() } > > . > > . > > . > > > > I would like to call the subroutine with one > > statement, something like this: > > > > $page = $in->param('page'); > > > > &page$page() > > > > but the "compiler" doesn't seem to substitute the > > variable $page before figuring out the name of the > > subroutine and it gives me an error. I thought > about > > loading the subroutine referencees into an array, > but > > run into the same problem. > > > > Is there a way to do this? Or is there a better > way > > for the beginning part of the script to play > traffic > > cop and direct it to the right page? > > > > Have you considered the CGI::Application module? It > works essentially as > you describe but has a good following, is likely > better tested, and may > provide a little more support structure. > > http://search.cpan.org/~markstos/CGI-Application-3.31/lib/CGI/Application.pm
I took a quick look at it and looks pretty interesting. But, I fooled around with my above code found out that if I put some curly brackets in the right place, I think it works: $page = $in->param('page'); &{page$page}() Thanks for the info! __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>