Term::Completion::Multi - read one line of user input with multiple values
use Term::Completion::Multi; my $tc = Term::Completion::Multi->new( prompt => "Enter your first names: ", choices => [ qw(Alice Bob Chris Dave Ellen Frank George Heidi Ida) ] ); my @names = $tc->complete(); print "You entered: @names\n";
Term::Completion::Multi is a derived class of Term::Complete. It allows to enter one line with multiple choices from a list of choices, delimited by a configurable delimiter character (typically one space). The return value of the
complete() method is the list of values.
See Term::Complete for details.
Term::Completion::Multi adds one additional configuration parameter, namely "delim". The default is one space. You can change this to e.g. a comma character if you prefer the user to separate the choices with a comma instead of a space:
my $tc = Term::Completion->new( delim => ',', ...
The input validation works very much like in Term::Completion. Here however the input is first split upon the delimiter character, and then each item is validated. Consecutive delimiter characters are treated as one. If any single validation fails, the entire input is cancelled. If all items validate OK, then the return value is built by concatenating the items returned from validation with the delimiter character.
If you don't like the above then you are free to write a class that is derived from Term::Completion::Multi and overrides the
Marek Rouchal, <firstname.lastname@example.org<gt>
Please submit patches, bug reports and suggestions via the CPAN tracker http://rt.cpan.org.
Copyright (C) 2009-2013 by Marek Rouchal
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.