Term::C...n::Multi(3)
π Term::Completion::Multi π
okay bestie, listen up β this is a page out of the User Contributed Perl Documentation manual (yes, the whole Term::C...n::Multi(3) situation), and it's genuinely one of the cutest little modules you'll ever meet. no cap.
β¨ NAME β¨
Term::Completion::Multi β read one line of user input with multiple values. like, the user types one line, but it secretly holds a whole lil squad of answers. iconic behavior honestly.
πΈ USAGE πΈ
here's the vibe, straight up:
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";
look at that. she prompts, she autocompletes, she hands you back a whole @names array. main character energy fr fr. π¦
π DESCRIPTION π
Term::Completion::Multi is a derived class of Term::Complete. it lets you enter one line containing multiple choices pulled from a list of choices, separated by a configurable delimiter character β typically one space, because we're not monsters.
and the return value of the complete() method? it's the list of values. plural. she gives you options. π
if you want the deep lore on how the base class works, go read Term::Complete. she's the mother. this module is the daughter and she ate.
βοΈ Configuration βοΈ
Term::Completion::Multi adds exactly one additional configuration parameter, and her name is delim.
the default is one space. but you can absolutely change it β say, to a comma character, if you'd rather your user separated choices with commas instead of spaces:
my $tc = Term::Completion->new(
delim => ',',
...
choose your delimiter, live your truth. β¨
π Validation π
the input validation works very much like in Term::Completion. HOWEVER β and this is the part people miss β the input is first split upon the delimiter character, and then each item gets validated.
a few things you need to know, no skipping:
- Consecutive delimiter characters are treated as one. so
a,,b-type shenanigans don't break anything, the extra ones just ghost. - If any single validation fails, the entire input is canceled. all of it. one bad apple and the whole basket's gone, bestie. π
- If all items validate OK, then the return value is built by concatenating the items returned from validation with the delimiter character. so what comes back is the validated versions, glued back together.
and if you don't like any of the above? you are free to write a class that is derived from Term::Completion::Multi and overrides the validate method. go off, queen. π
π 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>.
(that's the tracker link, don't @ me β submit it properly or it doesn't count π«Ά)
π 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.
ngl the legal bit is the least group-chat part of this whole page, but it matters. read it. it's short. you got this. π
and that's the whole thing, bestie β this page came to you from perl v5.42.0, dated 2025-07-25, originally living at Term::C...n::Multi(3) in the User Contributed Perl Documentation. slay, go autocomplete something multi-valued. πβ¨π
π¦ where this page comes from
- fedora 43: perl-Term-Completion 1.02-6.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms