The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Term::Completion::Multi - read one line of user input with multiple values

USAGE

  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";

DESCRIPTION

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.

Configuration

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 => ',',
    ...

Validation

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 canceled. 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 validate method.

SEE ALSO

Term::Completion

AUTHOR

Marek Rouchal, <marekr@cpan.org<gt>

BUGS

Please submit patches, bug reports and suggestions via the CPAN tracker http://rt.cpan.org.

COPYRIGHT AND LICENSE

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.