Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Term::Query 2.0

    Download button

    No screenshots available
    Downloads: 295  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Alan K. Stebbens | More programs
    Perl Artistic License / FREE
    November 3rd, 2006, 09:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Term::Query description

    Term::Query is a table-driven query routine.

    Term::Query is a table-driven query routine.

    SYNOPSIS

    use Term::Query
    qw( query query_table query_table_set_defaults query_table_process );
    $result = query $prompt, $flags, [ $optional_args ];
    $ok = query_table @array;
    query_table_set_defaults @array;
    $ok = query_table_process @array, &flagsub, &querysub;

    query

    The query subroutine fulfills the need for a generalized question-response subroutine, with programmatic defaulting, validation, condition and error checking.
    Given $prompt and $flags, and possibly additional arguments, depending upon the characters in $flags, query issues a prompt to STDOUT and solicits input from STDIN. The input is validated against a set of test criteria as configured by the characters in $flags; if any of the tests fail, an error message is noted, and the query is reattempted.
    When STDIN is not a tty (not interactive), prompts are not issued, and errors cause a return rather than attempting to obtain more input. This non-interactive behaviour can be disabled by setting the variable $Foce_Interactive as below:

    $Term::Query::Force_Interactive = 1;

    When $Force_Interactive is a non-null, non-zero value, query will issue prompts, error messages, and ask for additional input even when the input is not interactive.
    query_table

    The query_table subroutine performs multiple queries, by invoking query, setting associated variables with the results of each query. Prompts, flags, and other arguments for each query are given in an array, called a query table, which is passed to the query_table subroutine by reference.

    query_table_set_defaults

    The query_table_set_defaults subroutine causes any variables named in the given query table array to be assigned their corresponding default values, if any. This is a non-interactive subroutine.

    query_table_process

    A general interface to processing a query table is available with the query_table_process subroutine. It accepts a query table array, and two subroutine references, a &flagsub and a &querysub. The &flagsub is invoked on each each flag character given in the $flags argument of the query table (see below). The &querysub is invoked for each query in the query table.

    The query_table and query_table_set_defaults subroutines both use query_table_process to perform their functions.

    Query Table

    The format of the query table array passed to query_table, query_table_set_defaults, and query_table_process subroutines is:

    @array = ( $prompt1, $flags1, [ $arglist1, ... ],
    $prompt2, $flags2, [ $arglist2, ... ],
    ...
    $promptN, $flagsN, [ $arglistN, ... ] );

    In English, there are three items per query: a prompt string, a flags string, and an array of arguments. Note that the syntax used above uses [ ... ] to denote a Perl 5 anonymous array, not an optional set of arguments. Of course, if there are no arguments for a particular query, the corresponding anonymous array can be the null string or zero.

    The query table design is such that a query table can be created with a set of variables, their defaults, value constraints, and help strings, and it can be used to both initialize the variables' values and to interactively set their new values. The query_table_set_defaults subroutine performs the former, while query_table does the latter.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    table-driven query | query routine | Perl module | Term::Query | table-driven | query

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM