Andrew Main (Zefram) > Module-List-0.003 > Module::List

Download:
Module-List-0.003.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.003   Source  

NAME ^

Module::List - module `directory' listing

SYNOPSIS ^

        use Module::List qw(list_modules);

        $id_modules = list_modules("Data::ID::",
                        { list_modules => 1});
        $prefixes = list_modules("",
                        { list_prefixes => 1, recurse => 1 });

DESCRIPTION ^

This module deals with the examination of the namespace of Perl modules. The contents of the module namespace is split across several physical directory trees, but this module hides that detail, providing instead a view of the abstract namespace.

FUNCTIONS ^

list_modules(PREFIX, OPTIONS)

This function generates a listing of the contents of part of the module namespace. The part of the namespace under the module name prefix PREFIX is examined, and information about it returned as specified by OPTIONS.

Module names are handled by this function in standard bareword syntax. They are always fully-qualified; isolated name components are never used. A module name prefix is the part of a module name that comes before a component of the name, and so either ends with "::" or is the empty string.

OPTIONS is a reference to a hash, the elements of which specify what is to be returned. The options are:

list_modules

Truth value, default false. If true, return names of modules in the relevant part of the namespace.

list_prefixes

Truth value, default false. If true, return module name prefixes in the relevant part of the namespace. Note that prefixes are returned if the corresponding directory exists, even if there is nothing in it.

list_pod

Truth value, default false. If true, return names of POD documentation files that are in the module namespace.

trivial_syntax

Truth value, default false. If false, only valid bareword names are permitted. If true, bareword syntax is ignored, and any "::"-separated name that can be turned into a correct filename by interpreting name components as filename components is permitted. This is of no use in listing actual Perl modules, because the illegal names can't be used in Perl, but some programs such as perldoc use a "::"-separated name for the sake of appearance without really using bareword syntax. The loosened syntax applies both to the names returned and to the PREFIX parameter.

Precisely, the `trivial syntax' is that each "::"-separated component cannot be "." or "..", cannot contain "::" or "/", and (except for the final component of a leaf name) cannot end with ":". This is precisely what is required to achieve a unique interconvertible "::"-separated path syntax on Unix. This criterion might change in the future on non-Unix systems, where the filename syntax differs.

recurse

Truth value, default false. If false, only names at the next level down from PREFIX (having one more component) are returned. If true, names at all lower levels are returned.

use_pod_dir

Truth value, default false. If false, POD documentation files are expected to be in the same directory that the corresponding module file would be in. If true, POD files may also be in a subdirectory of that named "pod". (Any POD files in such a subdirectory will therefore be visible under two module names, one treating the "pod" subdirectory level as part of the module name.)

Note that the default behaviour, if an empty options hash is supplied, is to return nothing. You must specify what kind of information you want.

The function returns a reference to a hash, the keys of which are the names of interest. The value associated with each of these keys is undef.

SEE ALSO ^

Module::Runtime

AUTHOR ^

Andrew Main (Zefram) <zefram@fysh.org>

COPYRIGHT ^

Copyright (C) 2004, 2006, 2009, 2011 Andrew Main (Zefram) <zefram@fysh.org>

LICENSE ^

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

syntax highlighting: