On 2010.04.26 15:24, Harry Putnam wrote: > I want to try to describe briefly what problem I'm having. > But not show any working code.
That's ok, but it isn't clear to me that you have really described a problem that you are stuck on. > I guess where I get stuck is how to make a dispatch table where some > of the choices themselves may require more interaction. There are a few ways, depending on the situation you are facing. Recursion comes to mind, but without having descriptive code, it's hard to tell ;) > The example below is not working code and only here to try to > illustrate what I'm trying to do. Hopefully someone will know a > better approach or can give tips on this approach. > > ------- --------- ---=--- --------- -------- > (my %h = ( > a => \&func2, ## func2 requires no interaction > b => \&func3, ## func2 requires no interaction > > d => sub ( pdiff() ##( And be prompted for user input > ## to add things to sub routine pdiff like ($var,@var) > ## run a diff on contents of vars passed in. > ## depending on results; > ## make a decision, (probably using another > ## dispatch table ), I'm a little confused here, possibly because of your use of non-descriptive variable names. If I understand what you are trying to achieve correctly, you likely want to reuse the existing dispatch table to execute one of your other options based on the result of this event... is that correct? iow, does your existing structure already handle all of the possible outcomes that could result from $h{ d }()? If so, you'd make a call back into the same table, using the return value of the original call to $h{ d }. I think that is what you are asking :) > > z => sub { ## check sizes of several file, then manipulate 1 or > ## more of them further, probably thru another > ## interactive dis_table }, In many cases, I like to build my dispatch tables so they are self-contained...ie. the code within each sub will either do something, or it is self-aware that it has a neighbour within the same dispatch hash that can do a task if necessary. Essentially, what I'm referring to is the 'rabbit hole' that I mentioned a few weeks back that helps (me) with automation. You made mention that you "made so much of a mess trying a lot of different things" (I snipped that out above)... can you provide some of your real example code that shows exactly what you've tried? Even extremely broken code that doesn't work at all is imho better than paraphrasing in many cases. Cheers, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/