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.

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