[Chicago-talk] humbling question

Ted Zlatanov tzz at lifelogs.com
Wed Sep 19 07:45:57 PDT 2007

On Wed, 19 Sep 2007 09:04:53 -0500 Ted Zlatanov <tzz at lifelogs.com> wrote: 

TZ> On Wed, 19 Sep 2007 06:18:03 -0700 (PDT) Richard Reina <richard at rushlogistics.com> wrote: 
RR> I am trying to write a simple program like the one below that lets
RR> users at a console select an active employee.  However, because they
RR> are not supposed to see the employee's employee number I can't
RR> figure out a way to let them make the selection.  I thought I could
RR> do it with a counter ($i) but don't know of a way to associate the
RR> date with the count.  Any ideas would be greatfully appreciated.

TZ> If you can get your choices into an array, the pick_one function below
TZ> will let your users pick with A through Z.  Larger lists won't work
TZ> (it's easy to add a "...more" choice activated by SPACE, for instance).
TZ> Any key that's not a valid choice exits the menu.  I wrote this for
TZ> myself, so let me know if it's useful to you.

TZ> The nice thing about it is that you can pass any list of values, as long
TZ> as you define a suitable formatting function ($info_sub).

Andy's suggestion of IO::Prompt is much better.  I haven't used it, but
it seems the -menu option will do a lot more than my pick_one function,
with two exceptions: it doesn't have the option of passing in a
formatter subroutine like my $info_sub parameter, so you have to
pre-format your options.  Also, it doesn't return the position of the
choice, since it accepts much more than a list of options.


More information about the Chicago-talk mailing list