Term::C...n::Multi(3)

πŸ“¦
version 1.02 Β· 2 versions
, in fedora 43

πŸ’– 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 (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