Shlomi Fish <shlo...@iglu.org.il> writes: > Hi Harry, > > thanks for replying inline (bottom posting). > > On Thursday 06 May 2010 16:19:32 Harry Putnam wrote: >> Shlomi Fish <shlo...@iglu.org.il> writes: >> >> >> [...] >> >> > sub dispatch >> > { >> > >> > my ($method, @rest_of_args) = @_; >> >> Not sure what $method is supposed to be doing. >> > > Sorry, I'm usually used to doing symbolic dispatches using object > instances and dynamic method lookups. So I can do something like:
[...] > And then have something like _handle_case_of_zebra() , > _handle_case_of_elephant(), _handle_case_of_tiger(), etc. > > Naturally, in this case $method should be better named as "$case" or > "$which" or something. Well, now that you've explained... I have no idea what you are talking about... sorry. [...] >> >> What I'm trying to do: >> >> Iterating through a list of lists using a dispatch table to >> `dispatch' one member of each list fed to it, or sometimes the >> whole list needs to be acted on. > > Are you iterating through an array of arrays? How do you determine > which handler to use for each array? Are they all treated the same > regardless of their context within the larger array? I'm working hard at getting a clear example... especially a working one or I'd try to outline.. what I'm doing. But briefly put: I'm walking through a large list one line at a time. Most often a single line of the large list (each line is one filename). will be sent through the disp table. For some situations... each line is stored in an array, and that array is sent thru the disp table. So all can be displayed and user can see what action is appropriate. Usually just one file in the array will be acted on, but sometimes it will be all of them. There will be one default_action that gets used most often by a wide margin, than maybe 3 other sub function that the table points to. Oh, and a couple of others... to just continue with no action or quit altogether. Those 4 named sub functions (or so) and 2 (continue,quit) I guess, are the handlers you asked about. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/