1Term::Completion::MultiU(s3e)r Contributed Perl DocumentaTteiromn::Completion::Multi(3)
2
3
4
6 Term::Completion::Multi - read one line of user input with multiple
7 values
8
10 use Term::Completion::Multi;
11 my $tc = Term::Completion::Multi->new(
12 prompt => "Enter your first names: ",
13 choices => [ qw(Alice Bob Chris Dave Ellen Frank George Heidi Ida) ]
14 );
15 my @names = $tc->complete();
16 print "You entered: @names\n";
17
19 Term::Completion::Multi is a derived class of Term::Complete. It allows
20 to enter one line with multiple choices from a list of choices,
21 delimited by a configurable delimiter character (typically one space).
22 The return value of the "complete()" method is the list of values.
23
24 See Term::Complete for details.
25
26 Configuration
27 Term::Completion::Multi adds one additional configuration parameter,
28 namely "delim". The default is one space. You can change this to e.g.
29 a comma character if you prefer the user to separate the choices with a
30 comma instead of a space:
31
32 my $tc = Term::Completion->new(
33 delim => ',',
34 ...
35
36 Validation
37 The input validation works very much like in Term::Completion. Here
38 however the input is first split upon the delimiter character, and then
39 each item is validated. Consecutive delimiter characters are treated as
40 one. If any single validation fails, the entire input is cancelled. If
41 all items validate OK, then the return value is built by concatenating
42 the items returned from validation with the delimiter character.
43
44 If you don't like the above then you are free to write a class that is
45 derived from Term::Completion::Multi and overrides the "validate"
46 method.
47
49 Term::Completion
50
52 Marek Rouchal, <marekr@cpan.org<gt>
53
55 Please submit patches, bug reports and suggestions via the CPAN tracker
56 <http://rt.cpan.org>.
57
59 Copyright (C) 2009-2013 by Marek Rouchal
60
61 This library is free software; you can redistribute it and/or modify it
62 under the same terms as Perl itself, either Perl version 5.8.8 or, at
63 your option, any later version of Perl 5 you may have available.
64
65
66
67perl v5.30.1 2020-01-30 Term::Completion::Multi(3)