On 2010.04.26 15:24, Harry Putnam wrote:
> I hope some of you will go along with this approach.
> 
> I want to try to describe briefly what problem I'm having.
> But not show any working code.
> 
> I've made so much of a mess trying a lot of different things I'd like
> to have some idea that at least theoretically I'm on the right track
> (or wrong track).
> 
> I guess where I get stuck is how to make a dispatch table where some
> of the choices themselves may require more interaction.

Also, (I've been away for a little while so I apologize if I missed any
references to this) Mark Dominus has very kindly provided his Higher
Order Perl book online for free (donations accepted on the site),
available via PDF download:

http://hop.perl.plover.com/

The book is so mentally twisting, that it will change the way you look
at Perl.

Most of it is still out of my grasp, but it will most certainly make you
think, and you will be able to take pieces from it each time you read
it, or refer to it.

You'd be interested in Chapter 2, but don't start there. Start from the
beginning, and work your way through. By far, my first time through, I
barely understood anything, but the farther I read, the more the small
things began to click.

Having a good understanding of references will certainly help, but even
if you are overwhelmed while reading, remember, you can always come
back. Not only that, it may enable you to try new things that will
expand your understanding of how to find what you are looking for, and
more importantly, where to look.

Dispatch tables are great, but I'm sensing that it may help you if you
get a briefing of recursion as well.

Cheers,

Steve

ps. still one of my very favourite quotes that I have ever read:

"I sometimes enjoy the mind-bending exercise of imagining the result of
memoizing the Unix fork() function." ...heh ;)




> 
> 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 ),
> 
>         z => sub { ## check sizes of several file, then manipulate 1 or
>                    ## more of them further, probably thru another
>                    ## interactive dis_table },
> 
>         l = sub { print "Moving on\n" and last;},
>         q => sub { print "Goodbye\n" and exit;},
>         error => sub { print "invalid selection\n" }
> );
> 
> while(1)
> {
>     print "press p to print (interactively) something to file\n",
>           "press d to see a diff of the files\n",
>           "press z to see file sizes, take more actions as required\n",
>           "press a to print something different",
>           "press s to skip current file, adding it to <$skipped_list>\n",
>       "-----     -----     --=--     -----     -----\n",
>           "press l (execute \`last') to continue on\n",
>           "press q to Exit (abort completely)\n";
> 
>     chomp(my $selection = <STDIN>);
> 
>     my $code = $dispatch{$selection} || $dispatch{'error'} ;
>     $code->();
> 
> }
> 
> 


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to