Shell::POSIX::Select

Shell::POSIX::Select is the POSIX Shell's "select" loop for Perl.
Download

Shell::POSIX::Select Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Timothy F. Maher
  • Publisher web site:
  • http://search.cpan.org/~yumpy/Shell-POSIX-Select-0.05/Select.pm

Shell::POSIX::Select Tags


Shell::POSIX::Select Description

Shell::POSIX::Select is the POSIX Shell's "select" loop for Perl. Shell::POSIX::Select is the POSIX Shell's "select" loop for Perl.PURPOSEThis module implements the select loop of the "POSIX" shells (Bash, Korn, and derivatives) for Perl. That loop is unique in two ways: it's by far the friendliest feature of any UNIX shell, and it's the only UNIX shell loop that's missing from the Perl language. Until now!What's so great about this loop? It automates the generation of a numbered menu of choices, prompts for a choice, proofreads that choice and complains if it's invalid (at least in this enhanced implementation), and executes a code-block with a variable set to the chosen value. That saves a lot of coding for interactive programs -- especially if the menu consists of many values!The benefit of bringing this loop to Perl is that it obviates the need for future programmers to reinvent the Choose-From-A-Menu wheel.SYNOPSISselect scalar_var ] ( ) { }In the above, the enclosing square brackets (not typed) identify optional elements, and vertical bars separate mutually-exclusive choices:The required elements are the keyword select, the parentheses, and the curly braces. See "SYNTAX" for details.ELEMENTARY EXAMPLESNOTE: All non-trivial programming examples shown in this document are distributed with this module, in the Scripts directory. "ADDITIONAL EXAMPLES", covering more features, are shown below.ship2me.plx use Shell::POSIX::Select; select $shipper ( 'UPS', 'FedEx' ) { print "nYou chose: $shippern"; last; } ship ($shipper, $ARGV); # prints confirmation messageScreen ship2me.plx '42 hemp toothbrushes' # program invocation 1) UPS 2) FedEx Enter number of choice: 2 You chose: FedEx Your order has been processed. Thanks for your business!ship2me2.plxThis variation on the preceding example shows how to use a custom menu-heading and interactive prompt. use Shell::POSIX::Select qw($Heading $Prompt); $Heading='Select a Shipper' ; $Prompt='Enter Vendor Number: ' ; select $shipper ( 'UPS', 'FedEx' ) { print "nYou chose: $shippern"; last; } ship ($shipper, $ARGV); # prints confirmation messageScreen ship2me2.plx '42 hemp toothbrushes' Select a Shipper 1) UPS 2) FedEx Enter Vendor Number: 2 You chose: FedEx Your order has been processed. Thanks for your business! Requirements: · Perl


Shell::POSIX::Select Related Software