Complete::Module - Complete with installed Perl module names


This document describes version 0.21 of Complete::Module (from Perl distribution Complete-Module), released on 2015-09-23.


 use Complete::Module qw(complete_module);
 my $res = complete_module(word => 'Text::A');
 # -> ['Text::ANSI', 'Text::ANSITable', 'Text::ANSITable::', 'Text::Abbrev']


$Complete::Module::OPT_SHORTCUT_PREFIXES => hash

Shortcut prefixes. The default is:

   df  => "DateTime/Format/",
   dzb => "Dist/Zilla/PluginBundle/",
   dzp => "Dist/Zilla/Plugin/",
   dzr => "Dist/Zilla/Role/",
   pwb => "Pod/Weaver/PluginBundle/",
   pwp => "Pod/Weaver/Plugin/",
   pwr => "Pod/Weaver/Role/",
   pws => "Pod/Weaver/Section/",

If user types one of the keys, it will be replaced with the matching value from this hash.



Can be used to set the default for $Complete::Module::OPT_SHORTCUT_PREFIXES. It should be in the form of:


For example:



complete_module(%args) -> any

Complete with installed Perl module names.

For each directory in @INC (coderefs are ignored), find Perl modules and module prefixes which have word as prefix. So for example, given Te as word, will return e.g. [Template, Template::, Term::, Test, Test::, Text::]. Given Text:: will return [Text::ASCIITable, Text::Abbrev, ...] and so on.

This function has a bit of overlapping functionality with Module::List, but this function is geared towards shell tab completion. Compared to Module::List, here are some differences: 1) list modules where prefix is incomplete; 2) interface slightly different; 3) (currently) doesn't do recursing; 4) contains conveniences for completion, e.g. map casing, expand intermediate paths (see Complete for more details on those features), autoselection of path separator character, some shortcuts, and so on.

Arguments ('*' denotes required arguments):

  • ci => bool

    Whether to do case-insensitive search.

  • dig_leaf => any


  • exp_im_path => bool

  • find_pm => bool (default: 1)

    Whether to find .pm files.

  • find_pmc => bool (default: 1)

    Whether to find .pmc files.

  • find_pod => bool (default: 1)

    Whether to find .pod files.

  • find_prefix => bool (default: 1)

    Whether to find module prefixes.

  • fuzzy => int

    Whether to do fuzzy matching.

  • map_case => bool

  • ns_prefix => str

    Namespace prefix.

    This is useful if you want to complete module under a specific namespace (instead of the root). For example, if you set ns_prefix to Dist::Zilla::Plugin (or Dist::Zilla::Plugin::) and word is F, you can get ['FakeRelease', 'FileFinder::', 'FinderCode'] (those are modules under the Dist::Zilla::Plugin:: namespace).

  • path_sep => str

    Path separator.

    For convenience in shell (bash) completion, instead of defaulting to :: all the time, will look at word. If word does not contain any :: then will default to /. This is because :: (contains colon) is rather problematic as it is by default a word-break character in bash and the word needs to be quoted to avoid word-breaking by bash.

  • word* => str

Return value: (any)


Please visit the project's homepage at


Source repository is at


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


perlancar <>


This software is copyright (c) 2015 by

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.