meetn2veg has asked for the wisdom of the Perl Monks concerning the following question:
Once again I find myself calling upon the combined experience of the collective mind...
Theatrical BS over with, here's the deal. In building a menu, the current data is stored in an array and using foreach $x etc... the sub builds a menu accordingly.
The final output of the entire left-hand menu consists of individual menu blocks. Each block's data is in its own array and each menu block is built by its own sub. By simply changing the order in which the subs are called changes the order in which the menu blocks appear in the final page.
I'd like to add a field to my data where the data will be for example, ["main_menu:sub_menu1:sub_menu2"] etc. Conducting a split push /\:/ on the data will give me the necessary array - $menu[$x][$y] : But how to use this value to form a subroutine name and call it in order to build the menu illudes me!
($menu = build_$menu[$x][$y]($other_data); isn't correct syntax)
Forward thinking prevents me from using a single routine containing if..then..else statements and passing the menu name to it - &build_menus($menu[$x][$y]); - as each menu will undoubtedly have different requirements.
Can anyone shed some monesterial light on this one for me?
Kind regards from Andorra
Richard.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using a variable value as part of routine name in order to call routine
by Zaxo (Archbishop) on Sep 21, 2003 at 01:21 UTC | |
|
Re: Using a variable value as part of routine name in order to call routine
by eyepopslikeamosquito (Archbishop) on Sep 21, 2003 at 03:32 UTC |