Term/Interact version 0.41 ========================== NAME Term::Interact - Interactively Get Validated Data SYNOPSIS use Term::Interact; my $ti = Term::Interact->new( @args ); # get validated data interactively $validated_data = $ti->get( @args ); # check existing data non-interactively die "Invalid!" unless $ti->validate( $data, @args ); DESCRIPTION Term::Interact enables you to interactively get validated data from a user. This is accomplished via a *simple* API, wherein you specify various parameters for prompting the user, as well as "checks" with which gotten data will be validated. VARIETIES OF CHECKS: Term::Interact comes with support for six varieties of check expressions: sql_check str: A text string starting with the word "SELECT". Will be used to generate a list of validation values from a database. Valid data is that which appears in the list. regex_check qr//: A compliled regular expression used to validate data. Valid data is that which matches the regular expression. list_check aref: An aref of values used to validate data. Valid data is that which appears in the list. compare_check str: A comparison test in string form. Valid data is that which satisfies the comparison test. filetest_check str: A filetest operator in string form. Valid data is that which satisfies the filetest operator. custom_check coderef: For special occasions, you can write your own custom check. This must be a reference to a function that returns true if the data is valid. To write your custom check function, follow the examples of the check functions in the source code of Term::Interact. NOTE ON AVAILABLE CHECK TYPES: This module steers clear of offering explicit checks like 'phone_number_check' or 'email_address_check'. In the author's opinion one may generally obtain all the convenience and code readability one needs via the built in varieties of checks. However, if you have regular need for an additional check you'll likely want to steer clear of the built in custom_check option (see above). You can more permanently add a your own custom checks by subclassing Term::Interact and providing the desired checks as a subroutines (all the check subs follow a simple API, just follow the pattern). Additionally you will need to modify the private _classify_check_type function. ONE EXAMPLE my $num1 = $ti->get( msg => 'Enter a single digit number.', prompt => 'Go ahead, make my day: ', re_prompt => 'Try Again Here: ', check => [ qr/^\d$/, '%s is not a single digit number!' ] ); # # Resulting Interaction looks like: # # Enter a single digit number. # Go ahead, make my day: w # 'w' is not a single digit number! # Try Again Here: 23 # '23' is not a single digit number! # Try Again Here: 2 DOCUMENTATION For more examples and full documentation, see perldoc Term::Interact INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules: Text::Autoformat Term::ReadKey Date::Manip COPYRIGHT AND LICENCE Copyright (C) 2002 Phil R Lawrence. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.